On Mon, Nov 4, 2013 at 5:51 PM, Richard Curteis <lists / ruby-forum.com> wrote:
> Don't know how I missed that, I have ageChecker in the version I'm using
> here but it still returns the following error after returning what the
> user enters as age.
>
>
>
> ./revtest.rb:23:in `ageChecker': undefined local variable or method
> `age' for main:Object (NameError)
>   from ./revtest.rb:14:in `output'
>   from ./revtest.rb:57:in `<main>'
>
> Is this to do with with the variable 'age', not being exported from the
> output function?

Yes, variables are local to their scope. In your case, age is local to
the output method, once the method finishes, it ceases to exist.
Maybe you can have the variable age outside of the methods and pass it
as a parameter to them?

age = 27
ageChecker(age)

Jesus.