daz wrote: > h.each {|ek, ev| p [ek , ev ]} > h.each_with_index {|e, idx| p [e[0], e[1], idx]} ># ^_________^ ^_^ ^_^ ^^_^ ^_^ ># A B C D C E > > How about: irb(main):012:0> class Hash irb(main):013:1> alias_method :orig_each, :each irb(main):014:1> def each irb(main):015:2> index = 0 irb(main):016:2> orig_each do |ek, ev| irb(main):017:3* yield ek, ev, index irb(main):018:3> index += 1 irb(main):019:3> end irb(main):020:2> end irb(main):021:1> end => nil irb(main):022:0> h = {:a => 1, :b => 2, :c => 3} => {:c=>3, :a=>1, :b=>2} irb(main):023:0> h.each {|ek, ev| p [ek , ev ]} [:c, 3] [:a, 1] [:b, 2] => {:c=>3, :a=>1, :b=>2} irb(main):026:0> h.each {|ek, ev, idx| p [ek, ev, idx]} [:c, 3, 0] [:a, 1, 1] [:b, 2, 2] => {:c=>3, :a=>1, :b=>2} This, as you already know, doesn't work with Arrays: irb(main):027:0> def stuff irb(main):028:1> yield 1,2 irb(main):029:1> end => nil irb(main):030:0> stuff {|a| p a} (irb):30: warning: multiple values for a block parameter (2 for 1) from (irb):28 [1, 2] => nil But that's being warned about, so I hope that, in the future, 'a' will be set to 1, instead of [1,2]. (...which would make the above trick work for Arrays.) It wouldn't provide automatic "with index" functionality, as your hack does, but it seems (to me) to be the "cleanest" change to allow you to implement _with_index methods without polluting the methods list. Sorry if this is a rehash (no pun intended) of stuff covered in the ruby-core thread. Devin