From: Philip Mak Date: 2002-06-03T08:27:04+09:00 Subject: Re: $a = 5; $b = 'a'; print $$b On Mon, Jun 03, 2002 at 08:08:29AM +0900, Philip Mak wrote: > I tried eval(@key = vals[key]) and eval(@key) = vals[key] but those > didn't evaluate correctly. I think I got it. class Series attr_accessor :sid, :handle, :name def initialize(vals) vals.each_key { |key| eval("@" + key + "= vals[key]") } end end A bit kludgy looking (I'm porting something from Perl, and it abused the fact that classes are hashes in Perl) but it works.