[new to ruby] implicit function return values?

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” ?

On Apr 29, 5:00 pm, cban1 [email protected] 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 :slight_smile:

Is the implicit return basically just “the last thing the function
evaluated” ?

Yup

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs