From: Simon Krahnke Date: 2008-05-02T21:35:06+09:00 Subject: Re: Please explain nuances of ||= * Rick DeNatale (03:26) schrieb: > 1) In Ruby x ||= y does no assignment if x evaluates to true, and x > &&= y does no assignment if x evaluates to true. Eh, what? You are confusing me. &&= does an assignment only if x evaluates to true. The question of if there is an assignment in x = x is purely metaphysical: there is no way to tell. > 2) x || x = y, and x && x = y are much better first approximations of > how x ||= y and x &&= y than x = x || y, and x = x && y, despite what > K&R say. And doesn't explain why x springs into existence, if didn't exist before. > 3) I say first approximations because of David Black's observation > that x ||= y and x || x = y differ when x is undefined. Right, but x = x || y doesn't. The only thing special about x ||= y is that x is only ever evaluated once. But that's special in every op=. mfg, simon .... l