From: Chad Perrin Date: 2010-10-15T00:22:47+09:00 Subject: Re: Why does a lot of code not include parenthesis? --PNTmBPCT7hxwcZjr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 14, 2010 at 09:51:19AM +0900, Eric Christopherson wrote: >=20 > I'm not sure I follow. It sounds like you're saying that the > expression "o.foo" can mean either "invoke method foo on object o" or > "instance variable foo of object o", depending on how o is defined. > But AIUI "o.foo" can only ever mean the former. (That method might be > an accessor for an instance variable, but you still can't refer to an > instance variable directly using dot notation.) This is true but, to be fair, it can look an awful lot like direct access to the variable: > class Foo > def initialize(foo=3Dnil) > @foo =3D foo > end > attr_accessor :foo > end =3D> nil > o =3D Foo.new =3D> # > o.foo =3D 'foo' =3D> "foo" > puts o.foo foo =3D> nil --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --PNTmBPCT7hxwcZjr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAky3HxsACgkQ9mn/Pj01uKUPNACfY1SSGJmp4T0/kbGhQswu4+5P pD8AmwcQ33U32SEoCqpznhEj7A3HbRQm =5Vn+ -----END PGP SIGNATURE----- --PNTmBPCT7hxwcZjr--