Skip to content

Instantly share code, notes, and snippets.

@an0
Last active February 28, 2016 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save an0/6fd2e492ea6e00ddfb10 to your computer and use it in GitHub Desktop.
Save an0/6fd2e492ea6e00ddfb10 to your computer and use it in GitHub Desktop.
isKindOfType
public func isKindOfType<T>(type: T.Type, value: Any) -> Bool {
return value is T
}
class A {}
class B: A {}
let clsA = A.self
let b = B()
struct S {}
let s = S()
isKindOfType(clsA, value: b)
isKindOfType(S.self, value: s)
isKindOfType(Int.self, value: 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment