Puts and prints question?


#1


I just have a question as to why when running puts and print
i get a 'nil' on the end. What does nil represent?

Thanks



#2

Consider the console as a terminal. When we enter a command it goes to the CPU and gets evaluated and executed. Once execution is complete the response to the console will be nil. It's the nature of the console, at least this version of it, and can be ignored.

nil is the response of function with no return. Ruby, or this interface, could be performing some clean-up duties or some such, which last function has no return.


#3

It's what these methods return. This is documented behaviour. I guess
Matz could think of a more sensible return value for puts and print when
designing Ruby :wink:


#4

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