How would you achieve the same accesses with rexml elements, to access subelements or attributes ? I guess it's possible, but I'm still a ruby newbie... CloD "Tim Hunter" <cyclists / nc.rr.com> a ñÄrit dans le message de news:pan.2004.02.15.02.53.29.298820 / nc.rr.com... > On Sun, 15 Feb 2004 02:47:07 +0000, Tim Sutherland wrote: > > > In article <8hvXb.37945$uV3.63269@attbi_s51>, Gavin Kistner wrote: > >>Although I may never use it, I thought I'd share the following > >>experiment. I find mildly frustrating the need to type: myHash['foo'] > >>to access a property of my hash, when for strings myHash.foo > >>seems perfectly logical. (At least to me, coming from JavaScript.) > > [...] > >>x = { 'name'=>'Gavin', 'age'=>31 } > >>x.weight = 171 > >>x.feet = ['left','right'] > >>puts x.name , x.weight , x.foo , x.inspect > > [...] > > > > Are you familiar with the `Struct` class? > > > > Person = Struct.new(:name, :weight, :age, :feet) > > > > gavin = Person.new('Gavin', 171, 31, ['left', 'right']) gavin.name # -> > > 'Gavin' > > gavin.weight # -> 171 > > gavin.age += 31 # -> 32 > > Also the OpenStruct class. Check out ostruct.rb.