News for hackers. Stuff that matters.
Re:Confident Code by prosa on Thursday November 10, 2011 @12:40AM (#3219087)
Also, you can't make a Ruby object falsy. So if you overload #nil? you get fun problems like:

    obj.nil? # => true
    !!obj    # => true
Re:Confident Code by zwp on Thursday November 10, 2011 @03:49AM (#3219464)
> can't make a Ruby object falsy

You can override ! (see http://www.rubyinside.com/rubys-unary-operators-and-how-to-r... from earlier this week) so !!obj can evaluate to false. But there is still this to solve:

    ruby-1.9.3-p0 :008 > obj ? true : false
     => true 
    ruby-1.9.3-p0 :009 > 
If only there was a #to_bool to override...

(For the record: yuck).