+ 1

What is the difference between length, count and size?

Differences with respect to array and ruby.

12th Dec 2019, 7:17 AM
Pawan Bharti
Pawan Bharti - avatar
2 Answers
+ 2
length returns the length of an array only, it dosen’t accept any additional arguments. size is a just alias of length. count can accept condition and count on it. So, length or size are prefered when you just need to know the size of an array. count - when you need to count elements by some condition.
13th Dec 2019, 2:00 PM
Alex Tatarnikov
If you are talking of arrays, all these terms have different contextual meaning. Read on datastruct
12th Dec 2019, 9:52 AM
Da2 - avatar