Floating Point Results in Ruby

Sometimes it's the little things.

Today I couldn't figure out the syntax that would tell Ruby to give me a fraction result -- that is, a floating-point answer instead of an integer. 

> 5/3

 => 1 

The rule is that one of the numbers has to be floating point to get a floating point result. And if none is, you make one so! Adding .to_f (to float) makes the 3 into 3.0000000 ... and we're set.

 > 5/3.to_f

 => 1.66666666666667 

Thanks to Melvin Ram for being on the other end of my Google search.