-
-
Notifications
You must be signed in to change notification settings - Fork 5
optional
pannous edited this page Nov 5, 2020
·
7 revisions
To avoid null errors Angle offers the swift way
class car{
name:string // default
name:string! // required
year:date? //optional
}
Fields can be made required in function declarations via with
keyword or nested schemas:
age of car with year = car.year
age of car{year} = car.year
The scheme of the type can be deep:
arrival time of package{destination{address{zip or street}}} = calculate distance to zip …
make optionally as unknown
default but enable way to specify the requirement of fields:
to get movie time of user with name and zip:...
to place order for user with last name and address:...
Julia style
movie-time (user:{name, address: zip} ) = ...
Nested optionality thanks to Rick Hickey from closure
These required attributes can also be inferred from the compiler:
peter{last-name=fox zip=1234}
movie-time(peter) // compiler warning/error: movie time requires peter to have a name
// extra: did you mean lastname?