Has anyone used functions to return a value before? I could jump
through a ton of hoops to get this to work, - like manually checking
each input or setting up individual local vars, but thought there might
be a more elegant way to do this.
thanks.
Bob wrote:> I thought this would be simple, but I just cant seem to get it to work.
>
> # only allow numbers. Need to check for nil / NAN
> def saveHours(val)
> if val < 0
> val = 0
> end
> return val
> end
>
> current_item.product.v1 = checkValue(values[:val1])
> current_item.product.v2 = checkValue(values[:val2])
>
> but when I run the code, nothing is ever returned from the checkValue
> function. If I remove the function call and just have values[:val1]
> things work fine.
>
> Ive also tried removing the return and just having ''val''
as the last
> function line, but I get the same result. I tried placing this function
> in a helper file and in the same file that the other code is in, but no
> luck.
>
> Any ideas?
--
Posted via http://www.ruby-forum.com/.