From: Larry Fast Date: 2007-08-27T05:24:31+09:00 Subject: Re: class X < Hash ... how do I do X.new { |hash, key| ...} Thank you both. Yes, that works. So I'm puzzled by the error I was getting. Oh well, carrying on... I still have a related problem. I'm using YML to export and import my Hash. YML loses all the Hash initialization settings. So I may still have to create a new internal Hash after reloading from YML. class X < Hash attr_accessor :attempts def initialize self.attempts = [] super {|h,k| attempts << k unless h.has_key?(k); nil } end end h = X.new h[1] = 2 p h[1] # 2 p h[0] # nil p h[2] # nil p h.attempts # [0,2] yml_text = YAML.dump(h) # "--- !map:X \n1: 2\n" j = YAML.load(yml_text) # {1=>2} j.class # X j.attempts # nil j[2] = 25 # 25 j # {1=>2, 2=>25} j[3] # nil j.attempts # nil -- Posted via http://www.ruby-forum.com/.