Skip to content

Instantly share code, notes, and snippets.

@filimo
Last active February 19, 2020 21:13
Show Gist options
  • Save filimo/1d466d8f40c0f61b006a9c3965d8498e to your computer and use it in GitHub Desktop.
Save filimo/1d466d8f40c0f61b006a9c3965d8498e to your computer and use it in GitHub Desktop.
protocol AssotiatedTypeProtocol {
func bar()
}
class BaseClass: AssotiatedTypeProtocol {
func bar() {
print("BaseClass")
}
}
class Class1: BaseClass {
override func bar() {
print("Class1")
}
}
class Class2: BaseClass {
override func bar() {
print("Class2")
}
}
var objs: [BaseClass] = [Class1(), Class2()]
objs[0].bar()
objs[1].bar()
var objs: [AssotiatedTypeProtocol] = [Class1(), Class2()]
objs[0].bar()
objs[1].bar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment