`
Gene
  • 浏览: 50558 次
社区版块
存档分类
最新评论

Common array query methods in Ruby

    博客分类:
  • Ruby
阅读更多

Method name/sample call        Meaning

a.size (synonym: length)             Number of elements in the array
a.empty?                             True if a is an empty array; false if it has any elements
a.include?(item) True if the array includes items; false otherwise
a.any? {|item| test } True if any item in the array returns true for the block;
false otherwise
a.all? {|item| test } True if every item in the array returns true for the block;
false otherwis
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics