Skip to content

Instantly share code, notes, and snippets.

@hvsw
Last active February 15, 2016 05:44
Show Gist options
  • Save hvsw/92c68028d8ad53136161 to your computer and use it in GitHub Desktop.
Save hvsw/92c68028d8ad53136161 to your computer and use it in GitHub Desktop.
func divide(x: Float, _ y: Float) throws -> Float {
guard x != 0 else {
throw DivisionErrorEnum.DividendIsZero(message: "You’re trying to divide 0")
}
guard y != 0 else {
throw DivisionErrorEnum.DivisorIsZero(message: "You’re trying to divide \(x) by 0")
}
return x/y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment