From: Tom Sawyer Date: 2003-01-23T12:44:01+09:00 Subject: Re: Hash#+ ? On Wednesday 22 January 2003 07:20 pm, Daniel Carrera wrote: > > David, what value can be lost? i don't understand. > > hash1 = { "key1" => "foo", "key2" => "bar" } > hash2 = { "key1" => "baz", "key3" => "blah" } > hash1 + hash2 # -> What is the value for "key1"? i see what youre saying. indeed, + is not really the right method for this. > I like the idea of Hash#| or Hash#or. It is simply an 'or' function. > Whichever comes first has precedence: > > hash1 | hash2 # -> "key1" => "foo" > hash2 | hash1 # -> "key1" => "baz" i posted this RCR on Ruby Garden but i expect the second hash to have precedence. i.e. | is defined as a non in-place #update. -- tom sawyer, aka transami transami@transami.net .''. .''. . *''* :_\/_: . :_\/_: _\(/_ .:.*_\/_* : /\ : .'.:.'. .''.: /\ : ./)\ ':'* /\ * : '..'. -=:o:=- :_\/_:'.:::. | ' *''* * '.\'/.' _\(/_'.':'.' : /\ : ::::: = *_\/_* -= o =- /)\ ' * '..' ':::' === * /\ * .'/.\'. '._____ * | *..* : |. |' .---"| * | _ .--'| || | _| | * | .-'| __ | | | || | .-----. | |' | || | | | | | || | ___' ' /"\ | '-."". '-' '-.' '` |_. ------------------------------------------------------------