You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-8Lines changed: 13 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -165,22 +165,27 @@ Comparison:
165
165
find: 0.2 i/s - 3137489.63x slower
166
166
```
167
167
168
-
##### `Array#count` vs `Array#size`[code](code/array/count-vs-size.rb)
168
+
##### `Array#length` vs `Array#size` vs `Array#count`[code](code/array/length-vs-size-vs-count.rb)
169
+
170
+
Use `#length` when you only want to know how many elements in the array, `#count` could also archieve this. However `#count` should be use for counting specific elements in array. [Note `#size` is an alias of `#length`](https://github.com/ruby/ruby/blob/f8fb526ad9e9f31453bffbc908b6a986736e21a7/array.c#L5817-L5818).
0 commit comments