From: Peter Date: 2004-03-01T19:43:01+09:00 Subject: Re: turn hash into object variables? > I tried to replace the "def #{key} ..." with "attr_reader > :#{key}.intern", but that didn't work, for some reason that I don't have > time to look at. I'd be interested to hear from anyone who can explain > why it doesn't. attr_reader is defined in Module, so it can be used in module and class definitions. It is not defined in Object or so, so you can't call it on an instance, but that is what you were trying to do. You can add it to the object's singleton class though: instance_eval %Q{ class << self ; attr_reader #{key.intern.inspect} ; end } Peter