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
apple
=> 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.
https://tsubasa0105.hatenablog.com/entry/2018/11/03/015243
Recommended Posts