views:

100

answers:

3

I'm just starting with "The Well-Grounded Rubyist", and they gave the following example:

print "Hello. Please enter a Celsius value: "
print "The Fahrenheit equivalent is ", gets.to_i * 9 / 5 + 32, ".\n"

In particular, I'm looking at line 2, where they seem to be using commas for string concatenation. I assume the + symbol isn't being used because of the + 32 portion of the code. However, can someone explain to me what the commas actually are doing?

+1  A: 

Argument separators, i.e. print is called with three arguments.

antennen
+10  A: 

The commas are argument separators. The print method can take any number of arguments and will print them in sequence. Any string concatenation (if any occurs here) would take place inside the print method itself.

Chuck
+2  A: 

The commas are delimiting the arguments to the print function.

Felix Lange