From: Jason Persampieri Date: 2003-01-23T13:11:22+09:00 Subject: Re: Hash#+ ? --- Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Hash#+ ?" > on 03/01/23, Tom Sawyer writes: > > |> 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. > > So you guys are OK for value losing "or" or "|" methods? > > matz. Just an idea, can Hash#| check to see if the data types of the conflicting keys already HAVE an '|' method (assuming the data types are the same, of course)? That way, we can do something like this... Hash1 is {"key1"=>["val1"]} Hash2 is {"key1"=>["val2"]} Hash1 | Hash2 gives {"key1"=>["val1", "val2"]} Or should that be a different method altogether? Jason