mirror of
https://github.com/Dummi26/mers.git
synced 2026-01-26 10:47:04 +01:00
add objects and object types
This commit is contained in:
@@ -46,16 +46,20 @@ double := x -> {
|
||||
// Define custom types:
|
||||
// `[[MyType] TypeDefinition]`
|
||||
|
||||
[[City] (Int, Int, Int)]
|
||||
[[City] {
|
||||
population: Int
|
||||
pos_x: Int
|
||||
pos_y: Int
|
||||
}]
|
||||
|
||||
get_coords := city -> [(Int, Int)] {
|
||||
// only works with values of type City
|
||||
(_, x, y) := [City] city
|
||||
{ population: _, pos_x: x, pos_y: y } := [City] city
|
||||
// return the coords
|
||||
(x, y)
|
||||
}
|
||||
|
||||
test_city := (56000, 127, -12)
|
||||
test_city := { population: 56000, pos_x: 127, pos_y: -12 }
|
||||
|
||||
("Coords: ", test_city.get_coords).concat.println
|
||||
|
||||
|
||||
Reference in New Issue
Block a user