Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to puts arguments in one line?

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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!

enter image description here

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.

>Solution :

>> a, b = "bar", "tree"
>> puts [a, b].join(", ")
bar, tree

or print:

>> print a, ", ", b, "\n"
bar, tree
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading