From: Yukihiro Matsumoto Date: 2009-11-09T19:13:28+09:00 Subject: Re: Hash#count Hi, In message "Re: Hash#count" on Thu, 5 Nov 2009 01:19:13 +0900, Intransition writes: |Current: | | {:a=>1,:b=2,:c=>1}.count([:a,1]) #=> 1 | {:x=>1,:b=2,:c=>1}.count([:a,1]) #=> 0 | {:a=>1,:b=2,:c=>1}.count(1) #=> 0 | |Proposed: | | {:a=>1,:b=2,:c=>1}.count(1) #=> 2 | {:x=>1,:b=2,:c=>1}.count(1) #=> 2 | |It would be more useful that way. That is based on viewpoint to see hashes are collections of values indexed by arbitrary object. But in reality, Ruby hashes are designed as collections of key-value pair. I am not particularly against the object-indexed view, but I am not going to change the existing method behavior. |And, in the same vain, a #has_pair? |seems like an obvious addition. Let's address the issue one by one. matz.