From: David MacMahon Date: 2013-08-14T11:09:27-07:00 Subject: [ruby-core:56616] Re: [ruby-trunk - Feature #8772] Hash alias #| merge, and the case for Hash and Array polymorphism On Aug 14, 2013, at 10:41 AM, alexeymuranov (Alexey Muranov) wrote: > The #<< operator does quite a different thing than either #merge or #reverse_merge: > > [1,2] << [3,4] #=> [1, 2, [3, 4]] Arrays are quite a different thing from Hashes, so it would not be surprising for Array#<< to do quite a different thing than Hash#<<, but the general concept in both cases is the same: "insert the operand into the receiver". In the case of Array, the operand can be inserted as-is. In the case of Hash, the operand cannot be inserted as-is because it's not clear whether to treat the operand as a key with a nil value (not very useful for Hash) or as a value with an unspecified key (also not useful for Hash). Instead, it does make sense to treat the operand to Hash#<< as a collection of key/value pairs to be inserted, which makes it very much like Hash#merge!. (All IMHO, of course.) Dave