From: Trans Date: 2006-08-18T03:45:12+09:00 Subject: Re: Multiple arguments for Hash#delete Daniel Schierbeck wrote: > Trans wrote: > > Also, it really doesn't work to redefine delete() as you originally > > suggested b/c you'd have to use the delete_values_at to ensure you get > > an expected result, otherwise you're assuming preknowledge of how many > > elemets are in the Hash. > > What do you mean? It would work fine for the purpose I've described. If > you want to be sure you get an array when deleting multiple key-value > pairs, use #delete_values_at, otherwise #delete is just fine. The nifty > thing is that it adjusts its return value according to your need. Yea, I'm just saying YAGNI b/c in the end you won't use delete() with more than one index, you'll use #delete_values_at b/c of the clear separation of functionality. But... > If #delete should be altered, why should #[] and #[]= ? You may have a point. Though it doesn't matter as much becuase it's much less often the anyone depends on the return value of []=. ie. we just use it to set values. But to be very percise it should probably be changed to match Array's. Consider that Array's []= method does take multuiple parameters related to slicing. Facets' deals with that by allowing it to also take an Array parameter: a = [] a[[1,2,3]] = :a, :b, :c a #=> [ :a, :b, :c ] Hash's can be made to do the same. What do you think? T.