NAME

sizeof - returns the total number of elements found in val

SYNOPSIS

val.sizeof()

DESCRIPTION

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.

RETURN VALUE

An Int containing the total number of elements of a value

ERRORS

ArgCheck if any arguments are passed

EXAMPLE

    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

SEE ALSO

shape
rank
length
stride
width