Kevin Nolan wrote: (snip) > or the compact version: > > val = (ptr = fcn_returning_ptr(...)) ? ptr->ref : DEFAULT > > Which, when I translate to Ruby yields (ActiveRecord example): > > unless (ar = Model.find(...)).nil? > val = ar.attribute > else > val = DEFAULT > > or the equivalent expression. > > It seems to me that this is very unRuby-like and I don't see any similar > usages in any of the code-bases in which I have looked. > > Will someone please provide a counter-example? Ruby has the ternary ?: operator, too: val = (ar = Model.find(...)) ? ar.attribute : DEFAULT -- Posted via http://www.ruby-forum.com/.