From: "Shot (Piotr Szotkowski)" Date: 2009-05-06T20:50:03+09:00 Subject: Re: '=||' --azLHFNyN32YCQGCU Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Eleanor McHugh: > class Test > def method_missing symbol, *args > puts "calling method #{symbol}" > end > end > t =3D Test.new > t[:a] ||=3D 17 > output: > calling method [] > calling method []=3D > Notice how even though method_missing > returns a value and is thus 'true' No, puts returns nil.=20 > the sequence still attempts all parts of the expression, and > t[:a] =3D t[:a] || 17 > output: > calling method [] > calling method []=3D > =3D> 17 > confirms that no short-circuited evaluation occurs. class Test def method_missing symbol, *args puts "calling method #{symbol}" true end end t =3D Test.new t[:a] ||=3D 17 # calling method [] t[:a] =3D t[:a] || 17 # calling method [] # calling method []=3D =E2=80=94 Shot --=20 Google Trends says CiviCRM is as popular as blueberry pancakes. Woo!! Next up: waffles! [Wes Morgan] --azLHFNyN32YCQGCU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkoBeWUACgkQi/mCfdEo8UoJmQCfdiSgcR2tuWbFZje3PzORnJDK 2DAAmwa3vt6YAsDWmlY+1m3Lu8klJLCQ =mjVs -----END PGP SIGNATURE----- --azLHFNyN32YCQGCU--