From: Quintus Date: 2012-04-12T03:32:29+09:00 Subject: Re: how does ruby parse/detect self.name= methods? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 11.04.2012 20:01, schrieb Roger Pack: > Hello. > > I am a bit confused. > > With this class: > > class A def go=(something) p 'in go=' end > > def test_go go=3 end end > > A.new.test_go # does not call go= A.new.go=3 # does call go= > > But it seems like I never run into this problem...so...how does > Ruby *ever* call a local :method= type method, since they're > always ambiguous? Or are they? Thanks! -roger- > `go=3' is _always_ a local variable assignment. No way to prevent that. What you can do is to tell Ruby the receiver: def test_go self.go=3 end This forces Ruby to look up the #go= method on self directly, bypassing the local variable guess. Vale, Marvin -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJPhc3LAAoJELh1XLHFkqhaKNgH/jWLhKZzdXFy6NhhzZVQziIn 8tDNLcHMlEnsHZze02Y8o4IRoh6N9lK9jpW3y+IPlKTUqx0e/f0TlN0ZqGWhtRjD HTEcm0a4gL6N+9mxZFlyOiBnu+v77No5JLc0zomfxIcd9qyVh8meCZFx3tijTkFI uNp63NuWBqXdTa8v/aQJ1OrltpKALGPqXr7kE8/DnW8xpL/BrdJHvvQJSuZ1VvwD 4PCq1jkV6BgHb7VmMtshYuCZi3t5Y7xIA74vLgaP7kJwvzcQR6q2BWB7fXVfnb2k Geh3EVnwCTgUus1d5BB1AaBISXIqtM7kck9Cjhs4jyMOSPoSoex1zLod1OSMERw= =Y3hG -----END PGP SIGNATURE-----