Get a Ruby hash with one element removed (non-destructive) -


i need new ruby hash based on existing hash 1 element removed , without affecting original hash. i'm sure it's simple, , i'm of ruby newbie spot it.

for example, if have plugh={:bar=>"bar", :baz=>"baz"} want able xyzzy=plugh.some_magic_goes_here(:baz) , xyzzy set {:bar=>"bar"} without affecting plughin way. how do it?

if are not using active support, can following:

xyzzy = plugh.reject { |k, _| k == :baz } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -