Count, size, length…too many choices in Ruby?

前端 未结 6 460
逝去的感伤
逝去的感伤 2021-01-29 20:18

I can\'t seem to find a definitive answer on this and I want to make sure I understand this to the \"n\'th level\" :-)


    a = { \"a\" => \"Hello\", \"b\" => \"Worl         


        
6条回答
  •  一生所求
    2021-01-29 21:09

    We have a several ways to find out how many elements in an array like .length, .count and .size. However, It's better to use array.size rather than array.count. Because .size is better in performance.

提交回复
热议问题