for some reason line 6 doesnt work.i converted it into a integer but
still i get the error ".
How_old_are_you?.rb:6:in `*': String can't be coerced into Fixnum
(TypeError)
from How_old_are_you?.rb:6
"
the * should work because i tried it. or if someone could tell me how to
do an input as a integer that would be great. but i would see of that
would have to work...
Comments
Re: how many seconds old am i?
By Alex Stahl at 10/06/2010 - 21:26You didn't save the result of .to_i.
That is to say, if you just do:
age.to_i
then that's all the machine does - creates a new int out of 'a'. But it
doesn't hold onto it if you don't tell it to. So you can either assign
it back to itself, somewhere else, or just call .to_i when it's actually
needed:
age = age.to_i
*or*
age_val = age.to_i
*or*
puts 86000*365*age.to_i
On Wed, 2010-10-06 at 20:00 -0500, Austin Delauney wrote:
Re: how many seconds old am i?
By Ryan Davis at 10/06/2010 - 23:24As much as I dislike doing someone's homework for them... *shudder* I can't help being anal about calendrical calculations...
There are 86400 seconds in a day, and a fractional number of days in a year (365.242199). You'd be off by more than 2 months for someone my age. Probably not a huge deal for something like this, but you'd be really late to the eclipse...
Re: how many seconds old am i?
By Austin Delauney at 10/07/2010 - 15:48Re: how many seconds old am i?
By Albert Schlef at 10/07/2010 - 00:43Ryan Davis wrote:
Are you... 240 years old?
(0.25 days * 240 years = 2 months)
Re: how many seconds old am i?
By Rick DeNatale at 10/07/2010 - 08:31On Thu, Oct 7, 2010 at 12:43 AM, Albert Schlef < ... at gmail dot com> wrote:
That might explain why Ryan seems to get, shall we say, a bit
crotchety at times. <G>
And I thought *I* was old.
Re: how many seconds old am i?
By Ryan Davis at 10/07/2010 - 15:00Pththththt
Re: how many seconds old am i?
By Phillip Gawlowski at 10/07/2010 - 02:18On Thu, Oct 7, 2010 at 6:43 AM, Albert Schlef < ... at gmail dot com> wrote:
You forgot to account for the lack of 400 seconds (6.666... minutes!) a day. ;)
Re: how many seconds old am i?
By Austin Delauney at 10/06/2010 - 21:07heres the file
Attachments:
<a href="http://www.ruby-forum.com/attachment/5134/how_do_you_do_.rb" title="http://www.ruby-forum.com/attachment/5134/how_do_you_do_.rb">http://www.ruby-forum.com/attachment/5134/how_do_you_do_.rb</a>