Principle of MOST surprise - aka ruby hazing 101

Posted by Tim Connor Thu, 16 Nov 2006 02:18:00 GMT

I suspect that the ruby Illuminati are going to have me killed for revealing this, because it seems to be a little booby-trap of goodness that is part of the learning experience, but WTF?!

irb(main):001:0> == 4
(irb):2: warning: Object#id will be deprecated; use Object#object_id
=> true

What this means, of course, is don’t be sloppy and assign from when object might be nil, with no check, or you’ll be in for a surprise. For example, you could end up assigning an object to an admin user, when it should have no user assigned.

Leave a comment