Skip to content

Glossary: Swift Beyond the Basics

try?

Also written: optional try

Runs a throwing call and gives `nil` instead of an error if it throws, turning the result into an optional. It is handy for a missing file (`try? Data(contentsOf:)`) or for ignoring a canceled sleep.

Where the book teaches it

Related terms

Task.sleepData