General
Return value is what is returned by the method. Output is what is done by the method
For example
Puts return a 'nil' object. However, puts's output displays the arguments into the screen.
Return value
With return value, you could chain methods.
For example
a = [1,2,3]
a.map { | num | num * 2 }.join
This will return an array [2,4,6]. Then , a join method is called upon the new array resulting in a string "246".
Return value is what is returned by the method. Output is what is done by the method
For example
Puts return a 'nil' object. However, puts's output displays the arguments into the screen.
Return value
With return value, you could chain methods.
For example
a = [1,2,3]
a.map { | num | num * 2 }.join
This will return an array [2,4,6]. Then , a join method is called upon the new array resulting in a string "246".
Comments
Post a Comment