Hi --

On Fri, 2 May 2008, Phillip Gawlowski wrote:

> However, a default value results in the Hash not evaluating to nil or
> false. Which is required for || and OR to use their *second* operand
> (since it otherwise uses the first operand), so x || x = y cannot work.
> Unless we get into precedence issues here, I guess.

It depends what you mean by work :-) See Robert's example.

> | Anyway, this is at least the third thread on this in recent months,
> | and I've written my blog post (and correction follow-up :-) about it.
> | I think I'm about ||='d out.
>
> So am I.

Whoops -- sorry :-)

I actually have a feeling we're talking at cross-purposes, and that
I'm somehow not getting something. All I'm saying is that h[x] ||=
value is the same as h[x] || h[x] = value, for any hash h and any key
x. That can be demonstrated easily (as Robert did) just by
substituting one expression for the other. It's an unusual case, but
it's legal. I'm not sure what would be needed beyond that to
demonstrate that x = x || y is not a drop-in replacement for x ||= y.


David

-- 
Rails training from David A. Black and Ruby Power and Light:
   INTRO TO RAILS         June 9-12            Berlin
   ADVANCING WITH RAILS   June 16-19           Berlin
   INTRO TO RAILS         June 24-27           London (Skills Matter)
See http://www.rubypal.com for details and updates!