Check whether Swift object is an instance of a given metatype

Viewed 2364

I need to keep a collection of Swift metatypes and write a function which will check if a given object is an instance of one of them. I can do that easily in Java:

Class c = x.getClass();
c.isInstance(someObj)

However, I have no idea how to do that in Swift:

var isInt = 7 is Int.Type // compiles

let x = Int.self
var isInt = 7 is x // compiler error - Use of undeclared type 'x'

Is this even possible to be done in Swift?

3 Answers
Related