Hi,

In message "Re: [ruby-core:25630] [Bug #2114] Array Hash inconsistency"
    on Fri, 18 Sep 2009 16:05:27 +0900, Wim Yedema <redmine / ruby-lang.org> writes:

|This is something I never really noticed until recently. There is some inconsistency between functions on Arrays and Hashes that requires you to repeat yourself needlessly if you want to be able to support both (breaking DRY):

Unlike other language like AWK or PHP, Arrays are NOT associative
array with number index, so they are just different.  I don't think
they need such consistency.

|function          | semantic                    | equivalent
|
|Array.delete(x)   | delete elements ==x         | No equivalent in Hash
|Hash.delete(x)    | delete element with key x   | Array.delete_at(x)

You can use #delete_if.

|Array.each(&b)    | apply b to each value       | Hash.each_value(&b)
|Hash.each(&b)     | apply b to each [key,value] | No equivalent in Array
|Hash.each_key(&b) | apply b to each key         | Array.each_index(&b)
|
|I realize this is not easy to change for some functions, but others can be simply added.