-
-
Notifications
You must be signed in to change notification settings - Fork 4
pannous edited this page Sep 30, 2021
·
1 revision
The as
keyword connects a value to a type.
In ordinary expressions it acts as cast operator:
pi as int == 3
In variable and function declarations it types the reference:
person as string
is semantically equivalent to other familiar syntaxes:
person:string
and
string person
The return type of a function is defined by the as
keyword:
fib i as int:= if i<2 : 1 else fib(i-1) + fib i-2
Interestingly if the last parameter is untyped, the as keyword also weakly hints at the parameter type.