Module: Tins::CountBy
- Defined in:
- lib/tins/count_by.rb
Instance Method Summary collapse
Instance Method Details
#count_by(&b) ⇒ Object
3 4 5 6 |
# File 'lib/tins/count_by.rb', line 3 def count_by(&b) b ||= lambda { |x| true } inject(0) { |s, e| s += 1 if b[e]; s } end |