//: Playground - noun: a place where people can play
class MyError: Error {}
protocol P {
func throwingFunc() throws -> Int
func nonThrowingFunc() -> Int
}
class A: P {
func throwingFunc() -> Int {
return 5
}
func nonThrowingFunc() -> Int {
return 5
}
}
class B: P {
func throwingFunc() throws -> Int {
throw MyError()
}
func nonThrowingFunc() throws -> Int {
throw MyError()
}
}
Swift Compiler Error Group
MyPlayground.playground:20:7: Type 'B' does not conform to protocol 'P'
MyPlayground.playground:7:10: Protocol requires function 'nonThrowingFunc()' with type '() -> Int'; do you want to add a stub?
MyPlayground.playground:25:10: Candidate throws, but protocol does not allow it