slovo/docs/language/examples/compat/v0/supported/struct.slo
2026-05-22 08:38:43 +02:00

18 lines
290 B
Plaintext

(module main)
(struct Point
(x i32)
(y i32))
(fn point_sum () -> i32
(+ (. (Point (x 20) (y 22)) x) (. (Point (x 20) (y 22)) y)))
(test "struct field access"
(= (point_sum) 42))
(test "struct field compares"
(= (. (Point (x 7) (y 9)) y) 9))
(fn main () -> i32
(point_sum))