Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class A { }
- let obj = A()
- let array: [AnyObject] = [obj]
- func isType<T, U>(x: T, type: U.Type) -> Bool {
- if let x = x as? U {
- return true
- } else {
- return false
- }
- }
- // This works
- if let array = array as? [A] {
- println(true)
- }
- // This works
- println(isType(obj, A.self))
- // This doesn't
- println(isType(array, [A].self))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement