Skip to content

Instantly share code, notes, and snippets.

@nameghino
Last active July 22, 2017 21:26
Show Gist options
  • Save nameghino/03d028dfddbc48308ff9d91a32147a41 to your computer and use it in GitHub Desktop.
Save nameghino/03d028dfddbc48308ff9d91a32147a41 to your computer and use it in GitHub Desktop.
Overloading Playground
class A { }
class B: A { }
class C: A { }
func play(_ a: A) {
print("playing with A")
}
func play(_ b: B) {
print("playing with B")
}
func play(_ c: C) {
print("playing with C")
}
let a = A()
let b = B()
let c = C()
play(a)
play(b)
play(c)
// What should happen here? What happens instead?
//let x: A = B()
//play(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment