nil is returned by puts. this means?

nil is returned by puts, what do you mean?

I've ignored it until now, but when you think about it, what does this mean?

irb(main):001:0> a = "apple"
=> "apple"
irb(main):002:0> puts a
=> nil

Looking at the above, I can see that there is apple in puts, but nil is returned.

As a premise, ** "output" and "return value (return value)" seem to be different **.

It doesn't mean the same thing.

Output` ``: Just display - Return value```: Returns a value and terminates the method

So, after all, puts are just for display.

Why do you need such a thing? Reference ↑ Just display it and say that it doesn't change the program itself. It's to eliminate waste.


Recommended Posts

nil is returned by puts. this means?