1

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?

3 Answers 3

10

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.

Sign up to request clarification or add additional context in comments.

Comments

2

The commas are delimiting the arguments to the print function.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.