mercredi 22 mars 2017

Comparing type of literal in swift fails?

This code works is Swift 3:

let a = 1
type(of: a) == Int.self // true

However, remarkably this code fails:

// error: binary operator '==' cannot be applied to two 'Int.Type' operands
type(of: 1) == Int.self

What is the syntax to make the second comparison work, if any?

Thanks a lot.





Aucun commentaire:

Enregistrer un commentaire