Skip to content

Instantly share code, notes, and snippets.

@ukitaka
Created October 25, 2017 07:46
Show Gist options
  • Save ukitaka/d4b4c8e50f52c539f9ec3c73a035a585 to your computer and use it in GitHub Desktop.
Save ukitaka/d4b4c8e50f52c539f9ec3c73a035a585 to your computer and use it in GitHub Desktop.
overload
protocol Animal {}
struct Dog: Animal {}
func hoge(_ any: Any) {
print("Any")
}
func hoge(_ dogOpt: Dog?) {
print("Optional<Dog>")
}
func hoge(_ animalOpt: Animal?) {
print("Optional<Animal>")
}
func hoge(_ animal: Animal) {
print("Animal")
}
func hoge(_ dog: Dog) {
print("Dog")
}
func hoge<A: Animal>(_ a: A) {
print("A: Animal")
}
hoge(Dog())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment