I understand these two methods are identical (one is defined in terms of the other) according to this previous question:
But is there a reigning best practice or recommended convention? I can think of three options:
(1) Always use size
(2) Always use length
(3) Use size
for all collections exception Array
I'm leaning towards (1) or (3). The rationale behind (3) is that these methods are inherited from Java. And in Java you'd be invoking collection.size()
and array.length
. The argument for (1) is that it builds on and simplifies (3). The argument for (2) I'm not really sure about.