Basic operations in rails

Hi all,
This must be such a beginner’s problem, but I can’t figure it out.

I’m pulling two integers out of a database, and i want to divide one
value with the other, but i keep getting an error about operating on
strings.
Here’s the code -

low_freq = unsorted.last.freq
high_freq = unsorted.first.freq
divider = high_freq / low_freq

In my view, if i display the contents of low_freq or high_freq there is
indeed an integer in there.

Can someone help a newb?

cheers

try this

low_freq = unsorted.last.freq.to_i
high_freq = unsorted.first.freq.to_i
divider = high_freq / low_freq

worked like a charm, thanks!

Emin H. wrote:

try this

low_freq = unsorted.last.freq.to_i
high_freq = unsorted.first.freq.to_i
divider = high_freq / low_freq