Array Count tips


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. array = [1,1,2,2,3,4,5]
  2. array.count # => 7
  3. array.count(1) # подсчитает количество элементов "1" => 2
  4. array.count{ |p| p > 2 } # подсчитает элементы по условию => 3

URL: http://habrahabr.ru/blogs/ror/91194/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.