Home Ask Login Register

Developers Planet

Your answer is one click away!

Vlad Cenan February 2016

Print multiple ruby variables on the same line

Is there any method to print multiple ruby variables on the same line? Like in the example below:

env = gets()
name = gets()
puts "Deleting #{name} in #{env}"

I'm trying to put this variables in a system (cmd) also, and I can't set these two variables in the same line... the output is :

Deleting name
in env

Thanks, Vlad


Wand Maker February 2016


env = gets().chomp
name = gets().chomp

Jörg W Mittag February 2016

Your code is working exactly as it should. Just remove the newlines from the two strings before printing them.

Post Status

Asked in February 2016
Viewed 2,142 times
Voted 10
Answered 2 times


Leave an answer

Quote of the day: live life