Skip to content

Instantly share code, notes, and snippets.

@anhnguyen1618
Last active May 28, 2021 06:32
Show Gist options
  • Save anhnguyen1618/327962f11dc7f2b250573b329429eb81 to your computer and use it in GitHub Desktop.
Save anhnguyen1618/327962f11dc7f2b250573b329429eb81 to your computer and use it in GitHub Desktop.
enum Color: Int {
case green
}
struct Test {
static func f<A>(_ z: A) {
print("Not enum")
}
static func f<A>(_ z: A) where A == Color {
print("Enum")
}
}
func g<K>(_ n: K) {
Test.f(n)
}
g(Color.green) // Not enum
g(1) // Not enum
Test.f(Color.green) // Enum
Test.f(1) // Not enum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment