Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Cocoa
- enum MathError:ErrorType{
- case argEmpty
- }
- func divide(arg0:Double,arg1:Double) throws -> Double{
- if arg0 == 0.00{
- throw MathError.argEmpty
- }else if arg1 == 0{
- throw MathError.argEmpty
- }else{
- return arg0 / arg1
- }
- }
- do{
- try print(divide(0, arg1: 5))
- }catch let exception{
- print("Caught exception: \(exception) (Argument cannot be 0)")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement