Zack Marrapese
Zack Marrapese

Reputation: 12080

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?

Upvotes: 1

Views: 456

Answers (3)

Felix Lange
Felix Lange

Reputation: 1582

The commas are delimiting the arguments to the print function.

Upvotes: 2

Chuck
Chuck

Reputation: 237010

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.

Upvotes: 10

runfalk
runfalk

Reputation: 1996

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

Upvotes: 1

Related Questions