sizeof - returns the total number of elements found in val
val.sizeof()
The sizeof()
method returns an
Int
containing the total number of elements
contained in a given val. For scalars, this is always one
element. For Dict
values, the
sizeof()
intrinsic returns the total possible
size of the dictionary.
This can be very useful in conjunction with the #[ ]
and #[ = ]
operators, since it
makes some operations on arbitrarily- dimensioned arrays easier to
code.
An Int
containing the total number of elements
of a value
ArgCheck
if any arguments are passed
a = [3,4].iterate() a.sizeof() 12 for (var i = 0; i < a.sizeof(); i++) { "", a#[i], ((i+1)<a.sizeof()) ? ' ' : '\n'; } 0 1 2 3 4 5 6 7 8 9 10 11 d = new Dict(4) d["one"] = 1 d.sizeof() 4 d.length() 1