From: timsuth@... (Tim Sutherland) Date: 2004-02-15T11:49:57+09:00 Subject: Re: Hash like JS Hash (code) 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 -- Tim Sutherland 2004 SDKACM President Software Developers' Klub - the University of Auckland ACM Student Chapter http://www.sdkacm.com/