Odin » Wiki

Odin Wiki

Featured Article: Built-in Procedures

Language level procedure

len

len :: proc(v: Type) -> int

The len built-in procedure return the length of v, according to its type:

Array: the number of elements in v
Pointer to array: the number of elements in v^ (even if v is nil)
Slice: the number of elements in v; if v in nil, len(v) is zero
Dynamic array: the number of elements in v; if v in nil, len(v) is zero
Map: the number of elements in v; if v in nil, len(v) is zero
String: the number of bytes in v

If the parameter passed is an enumeration type, it will return the number of enumeration values:

Foo :: enum {A, B, C};
#assert(len(Foo) == 3);

cap

cap :: proc(v: Type) -> int

The cap built-in procedure return the capacity of v, according to its type:

Dynamic array: the maximum length the dynamic array can reach before it requires a resize; if v in nil, len(v) is zero

size_of

align_of

offset_of

type_of

type_info_of

typeid_of

swizzle

complex

complex :: proc(r, i: Float_Type) -> Complex_Type
``
The `complex` built-in procedure constructs a complex value from two floating-point values. The floating point values must be of the ...