Jon Garvin
12/27/2006 5:20:00 PM
You need to convert the age string to a number. If you're coming from
Perl, you're used to this being done for you magically. Ruby expects
you to do it. Try this...
born = t.year - age.to_i
Ja Bo wrote:
> I am brand new to Ruby and I would greatly appreciate any help you guys
> can provide!
>
> If this is not the correct place to post them please let me know where I
> should post these types of questions.
>
> This very short program is just supposed to take today's date using t =
> Time.now and calculating what year the user was born...
>
> Code:
> puts "How old are you?"
> age = gets.chomp
>
> puts name + " is " + age + " years old."
>
> t = Time.now
> born = t.year - age
>
> puts "You were probably born in " + born + "."
>
>
> Thank you!!!
>
>