Open frroossst opened 1 year ago
This could just be a wrapper around a Suneido object
Sample class to emulate tagged unions.
result = class
{
New()
{
.err = false
.val = false
}
Ok(.val)
{
.err = false
}
Err(.err)
{
.val = false
}
Unwrap()
{
if .err isnt false
return throw .err
return .val
}
}
result = result()
result.Ok(123)
a = result.Unwrap()
Print(:a)
result.Err("uhhh")
a = result.Unwrap()
Print(:a)
It's no secret I love them, see if Suneido can natively support tagged unions or make a similar implementation with classes.