On Mon, Jun 14, 2010 at 5:48 PM, Roger Pack <rogerpack2005 / gmail.com> wrote:
> I read this once:
>
> Operator ||= can be shorthand for code like:
>        >
> How would that look like exactly, in shorthand, any guesses?


I don't know where you read that, but it has no basis in reality.  The
semantics of ||= have nothing to do with whether or not a method
exists.

The closest translation of

x ||= y

(x || x = y)

This is close, except that it will blow up if x isn't already defined.

another alternative might be

(defined? x) ? (x || x = y) : y

Which avoids the problem when x isn't defined, but isn't exactly what
the 'compiled' ruby code does, whether that 'code' is YARV 'byte
codes' or an AST in MRI pre 1.9

-- 
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Github: http://github.com/rubyredrick
Twitter: @RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale