Wu Language
  • Getting Started
  • Writing code
    • Declarations
    • Optionals
    • If and While
    • For
    • Switch
    • Functions
    • Structs
    • Module
    • Traits
Powered by GitBook
On this page
  1. Writing code

Optionals

Optional variable types are types that are allowed to contain a nil values:

foo: int? = 10
foo = nil
foo = 100

Optional types are denoted by a ?

We can safely unwrap an optional value, given that it exists, using !like this:

foo: str? = maybe_a_str()
bar: str = foo!
PreviousDeclarationsNextIf and While

Last updated 5 years ago