The ? (has value) operator should work with System.Nullable`1[T] and any other value that provides a has_value field or property.
For example given
some_thing[T](value: T) -> THING[T] => new THING[T](value);
none_thing[T]() -> THING[T] => new THING[T]();
struct THING[T] is
value: T;
has_value: bool;
init(value: T) is
has_value = true;
self.value = value;
si
init() is
si
to_string() -> string =>
if self? then
"some THING {value}"
else
"none THING"
fi;
si
The following should be supported:
let some = some_thing(42);
let none = none_thing`[int]();
write_line(some?); // print True
write_line(none?); // print False
The
?
(has value) operator should work withSystem.Nullable`1[T]
and any other value that provides ahas_value
field or property.For example given
The following should be supported: