From: Hal Fulton Date: 2012-04-06T07:17:07+09:00 Subject: Re: Call for comments - Structure --0015174be88665e76904bcf5e6cd Content-Type: text/plain; charset=ISO-8859-1 On Thu, Apr 5, 2012 at 5:00 PM, Robert Klemme wrote: > On Thu, Apr 5, 2012 at 5:18 PM, Hal Fulton wrote: > > 2012/4/5 Robert Klemme That I don't > understand, maybe that's the reason for the previous > discussion: for me it is fairly easy and straightforward > > Counter = Struct.new :value do > def incr(x = 1) > self.value += x > end > > alias to_i value > end > > I find that neither difficult nor impossible. What did you have in mind? > You are correct, of course. But it feels a little clumsy to me not to have direct access to the instance variables. That is purely subjective, and many will disagree with me. What about the automated conversion of a hash to an object with accessors? Note that from_hash will handle one level and parse_hash will proceed recursively. Am I the only one who likes obj.foo.bar better than obj['foo']['bar'] ? I have been exposed to a lot of JSON in the last week... ;) Hal --0015174be88665e76904bcf5e6cd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Thu, Apr 5, 2012 at 5:00 PM, Robert Klemme <shortcutter@googlemail.com> wrote:
On Thu, Apr 5, 2012 at 5:18 PM, Hal Fulton <rubyhacker@gmail.com> wrote:
> 2012/4/5 Robert Klemme <shortcutter@googlemail.com>That I don't understand, maybe tha= t's the reason for the previous
discussion: for me it is fairly easy and straightforward

Counter =3D Struct.new :value do
=A0def incr(x =3D 1)
=A0 =A0self.value +=3D x
=A0end

=A0alias to_i value
end

I find that neither difficult nor impossible. =A0What did you have in mind?=

You are correct, of course. But it feels a little= clumsy to me not to have
direct access to the instance variables. That= is purely subjective, and
many will disagree with me.

What about the automated conversion of a= hash to an object with accessors?
Note that from_hash will handle one l= evel and parse_hash will proceed
recursively.

Am I the only one w= ho likes obj.foo.bar better than obj['foo']['bar'] ?=A0
I have been exposed to a lot of JSON in the last week...=A0 ;)

<= br>Hal

--0015174be88665e76904bcf5e6cd--