# Output and return value

**URL:** <https://www.ruby-forum.com/t/output-and-return-value/192776>\
**Category:** Ruby\
**Created:** [August 5, 2010, 11:15am UTC](https://www.ruby-forum.com/t/output-and-return-value/192776 "2010-08-05T11:15:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amiref](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@amiref](https://www.ruby-forum.com/u/amiref)\
**Post date:** [August 5, 2010, 11:15am UTC](https://www.ruby-forum.com/t/output-and-return-value/192776/1 "2010-08-05T11:15:38Z")

</div>

Hi  
What is difference between “output” and “return value”? for example when  
we executed “puts 1+1” ruby outputs 2 and return nil.

---

<div class="post-metadata">

**Author:** ![amiref](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/41988e/32.png) [@amiref](https://www.ruby-forum.com/u/amiref)\
**Post date:** [August 5, 2010, 11:29am UTC](https://www.ruby-forum.com/t/output-and-return-value/192776/2 "2010-08-05T11:29:04Z")

</div>

On Thu, Aug 5, 2010 at 11:15 AM, Amir E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
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.
