3 ms·
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_ad
by samstokes 16y ago
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.