From: "prijutme4ty (Ilya Vorontsov)" Date: 2012-06-02T23:36:18+09:00 Subject: [ruby-core:45386] [ruby-trunk - Feature #6532] More methods for Hash and Array: Hash#has_all_keys? and family, Array#delete_at for multiple arguments Issue #6532 has been updated by prijutme4ty (Ilya Vorontsov). And of course I forgot the most useful method (more suggestions about names highly appreciate) Array#selection and Hash#selection alphabet = %w{a b c d e f g h i j} alphabet.selection(0,1,5,7) # ==> ['a','b','f','h'] {A: 1, T: 4, G: 3, C: 5}.selection(:A,:C,:G,:T) # => [1,5,3,4] I have several unsolved issues: 1)what's the proper name for a method; 2)whether this method should return array or enumerator 3) whether it should work with block like #map: {A: 1, T: 4, G: 3, C: 5}.selection(:A,:C,:G,:T){|el| el.to_f} # => [1.0, 5.0, 3.0, 4.0] or like #each {A: 1, T: 4, G: 3, C: 5}.selection(:A,:C,:G,:T){|el| print el} # => 1534 ---------------------------------------- Feature #6532: More methods for Hash and Array: Hash#has_all_keys? and family, Array#delete_at for multiple arguments https://bugs.ruby-lang.org/issues/6532#change-26975 Author: prijutme4ty (Ilya Vorontsov) Status: Open Priority: Normal Assignee: Category: Target version: I suggest introducing Hash methods: has_all_keys?, has_any_key?, has_none_key?, has_one_key? to write: input.has_all_keys? %w{A C G T} instead of: %w{A C G T}.all?{|letter| input.has_key? letter} and to write args.has_one_key?(:input_file, :input_string, :input_from_another_source, ...) instead of obvious but verbose code with iterating through keys Also I suggest reimplement method Array#delete_at to work with multiple keys: def delete_at(*args) args.sort.reverse{|index| current_version_of_delete_at index} end It helps not only writing multiple deletion code faster but also prevents mistakes with deleting elements from an array in arbitrary order -- http://bugs.ruby-lang.org/