Thanks David. Great book by the way. Easier for a beginner than
pickaxe. Ever considered writing a 'Ruby Projects' book. Start with
some simple program ideas and build them up to something useful?
Demonstrating all the syntax/conventions of Ruby. I'm happy to put down
a deposit!

Anyway,

> >  case age
> >  when age < 30
>
> Hang on....  Remember that a case statement works like this:
>
>    case a
>    when b
>
> is equivalent to:
>
>    if b === a
>
> So what you've got is:
>
>    if (age < 30) === age
>
> which is going to be either:
>
>    if true === age
>
> or
>
>    if false === age
>
> Neither of those is ever true when age is an integer, so the test will
> never succeed.


I don't quite understand I'm afraid. I have a variable I want to check
a number of conditions against. Can't i do this with the case
expression? Further explanation would be greatly appreciated.



>
> A simple if construct will work fine:
>
>    if age < 30
>      ...
>    elsif age > 75
>      ...
>    else
>      ...
>    end


Thats what I thought! What is the main advantage of case over if? Or
when would you be more likely to use one than the other?


>
> >    puts 'Sorry, too young.'
> >  when age > 75
> >     puts 'Sorry, too old.'
> >  else
> >     puts 'Hava a nice holiday!'
> >     return age
> >  end
> >  puts "Remember, age must be entered as two digits, e.g. 35"
> > end
> >
> > check_age
>
> No such method :-)


I tried wrapping that code in a method and got an error. The main thing
I am trying to understand is where to put the code to print out help.