Sizeof operator

The sizeof operator calculates the size of an object in bytes. It is not defined for types that can not be represented in linear memory like extern, exn, func, or any other types containing those types. It is also not defined for GC pointers, because their pointer size is opaque to code.

The sizeof operator works on both types and type instances, so e.g. using typeof before sizeof is unnecessary.

Example

The following example logs the sizes of different types to the console.