Unions
Unions can be declared through the use of the union keyword.
An example usage of unions in Scar is as follows:
pub union SomeUnion
Token(i32)
MultiPayload(i32, i32, f64)
StringPair(ref(u8), ref(u8))
end
pub def main()
var u = SomeUnion.Token(123)
var v = SomeUnion.StringPair("a", "b")
match v
Token (x) => (
@print("{d}", {x})
)
MultiPayload (_, _, _) => (
@puts("it was a multipayload")
)
StringPair (str, str2) => (
@print("{s} {s}", {str, str2})
)
end
end