unknown wrote:
> x ||= y is, I think, always supposed to be exactly equivalent to
> x = x || y, so that line in your first hash should be equivalent to:
> 
>    h[2] = 5 || 10
> 
> which should assign 5 to h[2]. It looks to me like you've found a bug.
> I can't think of any reason (and I really hope there isn't one,
> because having an exception to that ||= rule would be very messy) why
> using a default hash value would make any difference here. It's still
> 5 || 10 on the rhs, and it's still just an assignment.

I don't think it's a bug; the two examples are set forth on p. 276 of 
"The Ruby Way (2nd ed)".  However, no explanation is given for why the 
two examples work differently.
-- 
Posted via http://www.ruby-forum.com/.