ruby string concatenation (I think?)
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 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.
The commas are delimiting the arguments to the print function.
Argument separators, i.e. print is called with three arguments.
精彩评论