A.vec_size
You're seeing just the macro
vec_size
, go back to A module for more information.
Returns the size of a vector
.
It is implemented as a macro so that it can be used in guards.
When used outside of a guard, it will just be replaced by a call to A.Vector.size/1
.
When used in guards, it will fail if called on something else than an A.Vector
.
It is recommended to verify the type first.
Runs in constant time.
Examples
iex> import A
iex> match?(v when vec_size(v) > 20, A.Vector.new(1..10))
false
iex> match?(v when vec_size(v) < 5, A.Vector.new([1, 2, 3]))
true
iex> vec_size(A.Vector.new([1, 2, 3]))
3