------ art_177293_27561210.1169368634039 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/21/07, Trans <transfire / gmail.com> wrote: > > Seesm like there should be a mehtod for this: > > h :a, :b, :c } > > h.what_method(:a, :c) # { :a, :c } > ^^^^^^^^^^^ > > Or is there some other simple way we're supposed to do this? > > T. I will try to answer your question, but still it will be more questions :( Before thinking about the name, naming really is an art, I am thinking about the interface (1) So there is *args as above (2) Any object responding to #include? We need two names now, great job Robert ;) (1) #grep, wait a minute hash objects already have grep via Enumerable, no idea how it works for hashes though #filter or filter_keys #intersect might just be the wrong name #delete_unless ugly because delete_if takes a block form only my candidate is #for_keys {a, b, c}.for_keys("hi", :alpha) {"hi" 2} # for some values of a, b and c ;) Now to (2) #for_keys_from consistent but long (even ugly) #keys_from #intersect #use_keys #shadow maybe a different approach would be to define a method in Enumerable Enumerable#shadow_hash [*1..2].shadow_hash {a, b, c, d, e1} {1, 2} # see above this allows even for a call without the accolades. This all very vague but I feel that such methods would be very useful. Cheers Robert -- "The best way to predict the future is to invent it." - Alan Kay ------ art_177293_27561210.1169368634039--