Create a gist now

Instantly share code, notes, and snippets.

Embed
Error handling in swift
func square(val:Int) throws -> Int {
if val == 5 {
throw SampleError.sample1
}
return val * val
}
let sqaureValue = try! square(val: 10)
print(sqaureValue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment