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

Answers


Wand Maker February 2016

Use

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

Search




Leave an answer