From: Kev Jackson Date: 2005-10-24T17:34:28+09:00 Subject: Re: syntax quickie Christophe Grandsire wrote: >Selon Kev Jackson : > > > >>Hi all, >> >>What exactly does the following do and how can I test it? It looks like >>its creating a new value with the key name, but how do you call it? >> >>def [](name) >> @val[name] >>end >> >>Any help appreciated >> >> >> > >Just call it using array notation: foo[name]. Array notation is just syntactic >sugar for the method [](argument), i.e. foo[name] is the same as foo.[](name). > >So basically you have here an object that contains a hash as an instance >variable (named @val, not the clearest name ever chosen ;) ), and allows you to >directly read the values in that hash using array notation, as if the object was >a hash itself. >-- >Christophe Grandsire. > > Thanks, so I had actually accessed it by accident anyway :). Kev