From: Amir Ebrahimifard on 5 Aug 2010 05:15 Hi What is difference between "output" and "return value"? for example when we executed "puts 1+1" ruby outputs 2 and return nil. -- Posted via http://www.ruby-forum.com/.
From: Jesús Gabriel y Galán on 5 Aug 2010 05:28 On Thu, Aug 5, 2010 at 11:15 AM, Amir Ebrahimifard <amiref(a)ymail.com> wrote: > Hi > What is difference between "output" and "return value"? for example when > we executed "puts 1+1" ruby outputs 2 and return nil. Return value is what a method gives back as a result: a = method_call(parameters) a will contain the return value of the method "method_call" Output, I guess, is referring to showing things in the standard output device, for example a console. The method "puts", will write the parameters you pass to it to the console. Every method in Ruby returns something, apart from doing its internal job. In the case of "puts", after showing things to the console, will return nil. So if you do: a = puts("something") the word something will appear in the console and the value nil will be returned and assigned to the variable a. Jesus.
|
Pages: 1 Prev: Data::Dumper Request Next: Project name ownership and conflict |