I want to make it like in Python, 4 example:
print(
foobar,
footree,
foodrink
)
and it will be print in one line:
>>> "foobar, footree, foodrink"
In Ruby with the same code:
puts foobar,
footree,
foodrink
>>> "foobar"
... "footree"
... "foodrink"
Yes, I can do it with print, like this, but it looks ugly:
puts "foobar"
"foobar"
"foobar"
>>> "foobar, footree, foodrink"
Thx in advance!
Edited. Now I have the following "Align the arguments of a method call if they span more than one line" and in terminal it output from a new line, I need it in one line.
CodePudding user response:
You have to do
puts "#{foobar}, #{footree}, \
#{foodrink}"
CodePudding user response:
>> a, b = "bar", "tree"
>> puts [a, b].join(", ")
bar, tree
or print
:
>> print a, ", ", b, "\n"
bar, tree