iOS ● ● ○ Swift 6

Kodebits Day 24: Result Failure Path

May 17 2026
Practice error handling with a short swift challenge.

What is the output?

enum E: Error { case bad }
let r = Result<Int, E>.failure(.bad)
let v = r.map { $0 + 5 }
print(try? v.get())


Try it in the online Swift Playground →

[spoiler title="Solution"]

Answer:

nil

Explanation:

Mapping a failed Result keeps it failed, so try? returns nil.

[/spoiler]


Further Reading