Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment