News for hackers. Stuff that matters.
Re:Brilliance of Haskell's Maybe type and the Value of Stati... by samstokes on Monday July 26, 2010 @03:38AM (#1547407)
andand is a pretty nice tool when you're dealing with uncertain data. As well as the basic usage

    person.andand.occupation.andand.company.andand.billing_address
(which evaluates to nil if there's no person, or if they have no occupation, etc), my colleague pointed out the other day that you can pass it a block:

    Person.find(:name => "Bob").andand {|person| person.fire_out_of(cannon) }
which will perform a daring feat of acrobatics if Bob (a trained professional) is present, but safely do nothing if he isn't.

There are no comments on this comment yet.