thp/doc-generator/markdown/en/docs/latest/objects/definition.md
2023-03-28 19:18:06 -05:00

492 B

Definition

Objects are defined with the syntax #{}

Objects should have a definition that specifies which fields it accepts.

type Position = #{
    Num latitude,
    Num longitude,
}

val position = Position #{
    latitude: -93.0838749,
    longitude: 80.2847561,
}

// Destructure
val Position #{latitude: lat, longitude: long} = position

Arbitrary keys and values

val object2 = #{
    key1: "sample",
    key2: "text",
    key3: 322,
}

object2.key1