Last active
February 15, 2016 05:53
-
-
Save hvsw/b6e1b9f11e671acff735 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using optional try | |
let x = try? divide(0, 2) // (Yes you can use an if let/guard/whatever to unwrap it safely) | |
// Using do-catch | |
let y: Float? | |
do { | |
y = try divide(0, 2) | |
} catch { // exhaustive just for testing | |
y = nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment