Optional variable types are types that are allowed to contain a nil
values:
foo: int? = 10
foo = nil
foo = 100
{% hint style="info" %}
Optional types are denoted by a ?
{% endhint %}
We can safely unwrap an optional value, given that it exists, using !
like this:
foo: str? = maybe_a_str()
bar: str = foo!