Created
December 21, 2016 14:20
-
-
Save darthpelo/96d3f3a73e5092a5f7bc8047077643f8 to your computer and use it in GitHub Desktop.
Class check in Swift
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 foo { | |
let className = "foo" | |
} | |
let a = foo() | |
func isFoo(_ instance: Any) -> Bool { | |
return instance is foo | |
} | |
func check(_ instance: Any) { | |
if isFoo(instance) { | |
print("it is foo") | |
} else { | |
print("it is somenthing else") | |
} | |
} | |
check(a) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment