Skip to main content

Basic Types

Nylon's built-in types are the signed/unsigned integers, boolean, utf (a single Unicode code point), and binary (a fixed byte array):

i8 - A signed byte value
i16 - A signed short value
i32 - A signed integer value
i64 - A signed long value

u8 - An unsigned byte value
u16 - An unsigned short value
u32 - An unsigned integer value
u64 - An unsigned long value

byte - An unsigned byte value (equivalent to u8).
boolean - A boolean value.
utf - A utf-32 code-point.

binary - A fixed byte array value (equivalent to byte[]).

Values can be converted between these types explicitly:

let integer = i32(1)
let long = i64(integer)
let yes = boolean(integer)

Strings are represented through a string trait rather than one fixed implementation, giving the compiler freedom to choose the most efficient representation:

let text : string = "The quick brown fox jumps"

some, none, and unit​

Every type is ultimately a subtype of some. The absence of a value is none, similar to null in other languages:

let instance : some = Something()
let nothing = none
# Both of these checks are equivalent:
if (value is some) { ... }
if (value !is none) { ... }

unit represents "no meaningful information" — distinct from the absence of a value entirely:

# unit is a singleton value that exists but carries no information.
let instance = unit

# none is a non-value — the absence of a value.
let instance = none