Local Variables & Assignment
#
Fast IntroWhile document variables are persisted, variables can be defined locally within code blocks (like constructors, TODO complete listing of where code is defined).
#
Diving Into Details#
Define by typeEach native type can be defined within a code block:
Note, many types have a default value.
type | default value |
---|---|
bool | false |
int | 0 |
long | 0L |
double | 0.0 |
string | "" |
TODO: what about lists, arrays, ... etc...
#
Define via the "let" keyword and type inferenceInstead of leading with the type, you can simply say "let" and allow the translator to precisely infer the type.
#
readonly keywordA local variable can be annotated as readonly, meaning it can not be assigned.
Note: readonly and let do not mix at this time... TODO