From: "Shot (Piotr Szotkowski)" Date: 2009-08-27T07:32:33+09:00 Subject: Re: operators vs. methods --IS0zKkzwUGydFO0o Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Brian Candler: > (2) !~ and !=3D operators do not map directly to method > calls, but call :=3D~ and :=3D=3D and negate the answers > >> class Foo; def =3D=3D(bar); puts "=3D=3D #{bar}"; end; end > =3D> nil > >> Foo.new =3D=3D "x" > =3D=3D x > =3D> nil > >> Foo.new !=3D "x" > =3D=3D x > =3D> true That is true in MRI 1.8, but not in MRI 1.9, where !=3D can be specified (but does fall back to a negated =3D=3D if missing): >> class Foo; def =3D=3D(bar); puts "=3D=3D #{bar}"; end; end =3D> nil >> Foo.new =3D=3D "x" =3D=3D x =3D> nil >> Foo.new !=3D "x" =3D=3D x =3D> true >> class Foo; def !=3D(bar); puts "nooo, I=E2=80=99m not a negated =3D=3D!"= ; end; end =3D> nil >> Foo.new !=3D 'x' nooo, I=E2=80=99m not a negated =3D=3D! =3D> nil >> Foo.new =3D=3D 'x' =3D=3D x =3D> nil =E2=80=94 Shot --=20 For some reason, this signature reminds everyone of Marvin Zelkowitz. --IS0zKkzwUGydFO0o 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) iEYEARECAAYFAkqVt/0ACgkQi/mCfdEo8UrxSwCePMSUra5tk7ieIFD22C66cy2o msgAoM2n2aszLkKruNvuuAJmUOAYe88X =BSoL -----END PGP SIGNATURE----- --IS0zKkzwUGydFO0o--