shiika
shiika copied to clipboard
None as class
Shiika has special treatment for enum cases with no arguments such as Maybe::None
. While Some
evaluates to #<class Maybe::Some>
, None
evaluates to #<None>
, which is the only instance of the class Maybe::None
.
So you don't need to write .new
everytime you need None
.
a = Some<Int>.new(1)
b = None
However there are some cases where we want to denote the class None.
-
a = Result<None>.new
-
match x; when None
It is easy to add special handling for such cases to the compiler, but how to explain the rule?