From: Tony Arcieri Date: 2013-04-01T04:37:30+09:00 Subject: Re: Private setters can be called by self, why not getters? --001a11c1f4426f84bc04d93da266 Content-Type: text/plain; charset=ISO-8859-1 On Sun, Mar 31, 2013 at 12:20 PM, Josh Cheek wrote: > I rarely want to expose either. In my code example, why can I call > `self.count=` but not `self.count` ? > It's a hack, because setters require you to use "self.count=" syntax, whereas you can just call a getter with "count" Since there's no way to call a private setter except "self.count=", Ruby permits "self" as a receiver for this even if it's a private method. Clearly the more consistent thing to do would be for private methods to always permit "self" as a receiver. It's a bit odd Ruby doesn't allow this, IMO -- Tony Arcieri --001a11c1f4426f84bc04d93da266 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
On Sun, Mar 31, 2013 at 12:20 PM, Josh Cheek <josh.cheek@gmail.com> wrote:=
I rarely want to expose either. In my code example, why can I ca= ll `self.count=3D` but not `self.count` ?

It's a hack, because setters require you to use = "self.count=3D" syntax, whereas you can just call a getter with &= quot;count"

Since there'= ;s no way to call a private setter except "self.count=3D", Ruby p= ermits "self" as a receiver for this even if it's a private m= ethod.

Clearly the more consistent thing to do wou= ld be for private methods to always permit "self" as a receiver. = It's a bit odd Ruby doesn't allow this, IMO

--
Tony Arcieri
--001a11c1f4426f84bc04d93da266--