Variants (tweet) #4809
ggreif
started this conversation in
Show and tell
Replies: 1 comment
|
Scheduled for Friday 4/18 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Motoko has a neat feature where a datatype can have exactly one choice of many, and can also carry specific data. These are called variants and generalise other languages' enumerations.
You can (usually) figure which case you have at hand by performing a pattern match
example TBWAll reactions