I guess I’m still new enough to Ruby that this does not make sense to me:
>> nil.to_f => 0.0
Magically, from nothing, you have something. I suppose it might be convenient in places, but today I ran into a minor bug in Rails that causes problems when trying to get the average of a column that doesn’t have any entries.
So what is the reasoning behind
nil.to_f being 0.0 (and
nil.to_i being 0,
to_s being “”), anyway?