Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try? isLowerHalf(70) // nil
- try? isLowerHalf(20) // 20
- do {
- let value = try isLowerHalf(70)
- print("Yes, \(value) is in the lower half!")
- } catch is NotLowerHalf {
- print("Not in the lower half.")
- }
- if let value = try? isLowerHalf(20) {
- print("OK, that worked, and it's not _too_ weird.")
- }
- let result = try! isLowerHalf(40) // would cause a crash if it failed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement