From: Dale Martenson Date: 2002-03-29T23:40:53+09:00 Subject: RE: Now that's surprising. This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_001_01C1D72E.CB7ABA90 Content-Type: text/plain; charset="iso-8859-1" Chris Gehlker [mailto:gehlker@fastq.com] wrote: > Does anyone else think that the following little program is an instance of > Ruby violating the POLS by producing nil? I can fix it by uncommenting the > commented line but I don't think that that should be required. > > def truthTest > result = true > result = false unless result > # return result > end > > p truthTest Why is that so surprising? irb(main):001:0> result = true true irb(main):002:0> result = false unless result nil irb(main):003:0> "The return value of a method is the value of the last expression executed." -- so it is written (Pickaxe, bottom of page 230) ------_=_NextPart_001_01C1D72E.CB7ABA90 Content-Type: text/html; charset="iso-8859-1" RE: Now that's surprising.

Chris Gehlker [mailto:gehlker@fastq.com] wrote:
> Does anyone else think that the following little program is  an instance of
> Ruby violating the POLS by producing nil? I can fix it by uncommenting the
> commented line but I don't think that that should be required.
>
> def truthTest
>     result = true
>     result = false unless result
>     # return result
> end
>
> p truthTest

Why is that so surprising?

irb(main):001:0> result = true
true
irb(main):002:0> result = false unless result
nil
irb(main):003:0>

"The return value of a method is the value of the last expression executed."
-- so it is written (Pickaxe, bottom of page 230)

------_=_NextPart_001_01C1D72E.CB7ABA90--