Hi, Jeremy.

It seemed to be a good idea, but then I realized that it is actually not 
that good.

Because:

h={'test' => 123, ttt: 1234}               # => {"test"=>123, :ttt=>1234}
h=h.with_indifferent_access                # => {"test"=>123, "ttt"=>1234}
h.except(:ttt)                             # => {"test"=>123}
h.except2(:ttt)                            # => {"test"=>123, "ttt"=>1234}

As we can see, except2 method has different behaviour then except method. 
However I think I can fix it.

class HashWithIndifferentAccess < Hash
  def except2(*keys)
    dup.except!(*keys)
  endend 
h={'test' => 123, ttt: 1234}               # => {"test"=>123, :ttt=>1234}
h=h.with_indifferent_access                # => {"test"=>123, "ttt"=>1234}
h.except(:ttt)                             # => {"test"=>123}
h.except2(:ttt)                            # => {"test"=>123}


What do you think about it?

Regards, Dmitry.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to