The function of comma in this context


What is the function of the comma? Why does the code not work if i remove the comma?

95.upto(100) { |num| print num, " " }


method arguments are separated by comma


Hi, thanks for the reply. What do you mean by method arguments?


print is a method
you're giving it two arguments
since there is more than one, they need to be separated
and the separator is comma


This is what I understand from your answer. Print is a method, arguments are what you want to be pass into the method and to be printed out. So in this case the arguments are num(variable) and " "(string) whereby the , is the separator. To clarify further, string by itself is not an argument right? It will only be an argument if it is passed into some method. Also in this case does the variable num contains integer or string? Hope I am making sense. Programming has been tough for me. Your guidance is really appreciated.


What do you mean with string?

arguments are the values supplied to a method when calling a method

Argument means a value being sent to a method (or other callable) as input

Whether num refers to numbers or strings depends on what you're assigning to it, this assigning is being done by 95's upto method which is described here:


Hey thanks for answering my questions. I feel enlightened now :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.