From: Matt Mongeau Date: 2013-03-02T03:40:52+09:00 Subject: Re: Why class returns `null` but the definition not when their description ended in IRB? --047d7b60525ee1211204d6e157b8 Content-Type: text/plain; charset=ISO-8859-1 To be more explicit. The class is evaluated at definition, a method is evaluated when it is run. 2013/3/1 Matt Mongeau > Because that's how it is implemented. > > > 2013/3/1 Kumar R. > > The below class description returns its last evaluated expression : >> >> >> class A >> >> 1+7 >> >> 2+4 >> >> end >> => 6 >> >> To return `6` which method the expression generally called? >> >> But why the definition always `nil` ? >> >> >> def D >> >> 3+5 >> >> end >> => nil >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > --047d7b60525ee1211204d6e157b8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
To be more explicit. The class is evaluated at definition,= a method is evaluated when it is run.

=
2013/3/1 Matt Mongeau <= halogenandto= ast@gmail.com>
Because that's how it i= s implemented.


2013/3/1 Kumar R. <lists@ruby-forum.com>

The below class description returns its last= evaluated expression :

>> class A
>> 1+7
>> 2+4
>> end
=3D> 6

To return `6` which method the expression generally called?

But why the definition always `nil` ?

>> def D
>> 3+5
>> end
=3D> nil

--
Posted via http://= www.ruby-forum.com/.



--047d7b60525ee1211204d6e157b8--