> There's at least one thing I don't like: Since it's a
> delegator, operations on h2 directly affect h1. A pure
> functional approach would be more appropriate: Going from h1
> to h2 results in a copy of the data. When un_delegate'ing, we
> should once again copy the data. But that consumes a bit more
> memory... ;]
>
> (I'll work out the functional one and post it in a couple of
> minutes...)

That was easy... ;]

gegroet,
Erik V. - http://www.erikveen.dds.nl/

----------------------------------------------------------------

 --- hashy1.rb   2007-01-19 14:57:38.000000000 +0100
 +++ hashy2.rb   2007-01-19 14:57:44.000000000 +0100
 @@ -52,10 +52,12 @@
  if __FILE__ == $0
    h1   = {"a"=>111, "b"=>222}

 -  HashWithMethods.open(h1) do |h2|
 +  h3 =
 +  HashWithMethods.open(h1.dup) do |h2|
      h2.b       = 22222
      h2.c       = 33333
    end

    p h1
 +  p h3
  end

----------------------------------------------------------------