Ryan Leavengood
3/31/2007 8:59:00 PM
On 3/31/07, dwyer@o2.ie <JervisTown@ruby-lang.org> wrote:
> The following code leads to an error -
>
> temp.rb:5:in `*': String can't be coerced into Fixnum (TypeError)
>
> can someone explain the error to me so I can determine how to resolve it, Thanks a million!
>
> def c_f(temp)
> convert=((9/5)*temp)+32
> print "the coverted fig is ", convert
> end
> temp=gets.chomp
> Integer(temp)
> c_f(temp)
Calling Integer(temp) does not modify temp. I think you mean something like:
c_f(Integer(temp)) or c_f(temp.to_i)
Ryan