Skip to content

Instantly share code, notes, and snippets.

@mike3k
Created July 24, 2019 20:05
Show Gist options
  • Save mike3k/c07d0204df2ff23d70ef97ab0ab935cf to your computer and use it in GitHub Desktop.
Save mike3k/c07d0204df2ff23d70ef97ab0ab935cf to your computer and use it in GitHub Desktop.
protocol ImageProviderProtocol {
func image() -> UIImage?
}
class ImageProvider {
extension ImageProvider: ImageProviderProtocol {
func image() -> UIImage? {
return nil
}
}
class SomeOtherClass {
let imageProvider: ImageProviderProtocol
func returnImage -> UIImage {
return imageProvider.image() // <- shouldn't this give an error?
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment