Null Safety · 5.2
if let
All lessons are open — jump whenever you need.
if let safely unwraps an optional:
let value: int? = 42
if let v = value {
print("Value: {v}") // only runs if not nil
} else {
print("Was nil")
}Goal: Use if let to print the length of an optional name, or "Name not provided" if nil.
lesson-5-2.zolo
Program output
Run the code to see the output