Swift Any

作者: 幸运者_Lucky | 来源:发表于2020-08-13 10:03 被阅读0次

    Any can represent an instance of any type at all, including function types.

    Any 也可以代表可选性, 如下代码, 说得通, 但不应该.

    var a: Int?
    let b = a as Any
    if b != nil {
        print("b != nil, b == \(b)")
    }
    // print
    b != nil, b == nil
    

    reference: TypeCasting

    相关文章

      网友评论

        本文标题:Swift Any

        本文链接:https://www.haomeiwen.com/subject/zsfbdktx.html