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?
The commas are argument separators. The
printmethod can take any number of arguments and will print them in sequence. Any string concatenation (if any occurs here) would take place inside theprintmethod itself.