Generics – check the type

Hi there!

 

I have a problem while checking the type of a function parameter.

In Playground the following two lines result in “true”:

 

var test = [1.0,2.3,4.0]
print(test is Array)

 

On the other hand, the initializer of my class, defined as:

class Examine {
     public init(withObject object: Any) {
        super.init()
        print(object is Array)
        ...
     }
}

 

called as:

var test:Examine = Examine(withObject: [1.0,2.3,4.0])

produces “false

 

I don’t understand that.

Powered by WPeMatico

About

You may also like...

Comments are closed.