Forum: Ruby on Rails [new to ruby] implicit function return values ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A30e5c4c648d8b4b41c3b22fc0a0057f?d=identicon&s=25 cban1 (Guest)
on 2009-04-29 19:07
(Received via mailing list)
I'm sure this is a trivial question, but I'm a java/C programmer and
am not used to implicit returns.

If I have a function:

def check_range ( num )
  rng = 0..10

  rng.include?( num )
end

... does check_range evaluate to true or false depending on whether
'num' is in the range (based on the last line of the function)?

Is the implicit return basically just "the last thing the function
evaluated" ?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-29 19:09
(Received via mailing list)
On Apr 29, 5:00 pm, cban1 <caleb.banis...@gmail.com> wrote:
>
> ... does check_range evaluate to true or false depending on whether
> 'num' is in the range (based on the last line of the function)?
>

try it :)

> Is the implicit return basically just "the last thing the function
> evaluated" ?

Yup

Fred
This topic is locked and can not be replied to.