Skip to content

Instantly share code, notes, and snippets.

@darthpelo
Created December 21, 2016 14:20
Show Gist options
  • Save darthpelo/96d3f3a73e5092a5f7bc8047077643f8 to your computer and use it in GitHub Desktop.
Save darthpelo/96d3f3a73e5092a5f7bc8047077643f8 to your computer and use it in GitHub Desktop.
Class check in Swift
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