April 2012
2 posts
2 tags
Floats are mutable objects, apparently?
UPDATE[4/7]: Floats are NOT mutable apparently. Thank you to Robert for clarifying what is actually happening below. Read his comment below.
——————————
I just discovered another interesting tidbit while working with floats and modulos.
First this:
1.9.3p125 :001 > 3 % 0.05 => 0.049999999999999836
I haven’t...
2 tags
"Called id for nil, which would mistakenly be 4"
I’ve gotten this error so many times while building Rails applications and it didn’t make any sense. It usually appeared when I was trying to call Some_Object.id and the object wasn’t assigned correctly, so in essence I was calling .id on nil. But I had no idea why that would “mistakenly be 4”.
Thanks to Tim, I finally unraveled the mystery.
The first important...