Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Array#size
() -> ::Integer
size → integer
array.c
View on GitHub ↗
static VALUE
rb_ary_length(VALUE ary)
{
long len = RARRAY_LEN(ary);
return LONG2NUM(len);
}
Alias of #length
Returns the count of elements in self:
Example
[0, 1, 2].length # => 3 [].length # => 0
Related: see Methods for Querying.