Last active
July 22, 2017 21:26
-
-
Save nameghino/03d028dfddbc48308ff9d91a32147a41 to your computer and use it in GitHub Desktop.
Overloading Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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