Wu Language
Search…
Getting Started
Writing code
Declarations
Optionals
If and While
For
Switch
Functions
Structs
Module
Traits
Powered By
GitBook
Optionals
Optional variable types are types that are allowed to contain a
nil
values:
1
foo
:
int
?
=
10
2
foo
=
nil
3
foo
=
100
Copied!
Optional types are denoted by a
?
We can safely unwrap an optional value, given that it exists, using
!
like this:
1
foo
:
str
?
=
maybe_a_str
()
2
bar
:
str
=
foo
!
Copied!
Previous
Declarations
Next
If and While
Last modified
2yr ago
Copy link