[swift-users] Dictionary<String, AnyObject> can accept Bool as a Value, but my own function can't

zh ao owenzx at gmail.com
Tue May 24 23:07:52 CDT 2016

See the code:

do {

    var dictionary = Dictionary<String, AnyObject>()

    func update<T:AnyObject>(value:T, key:String) {

        dictionary.updateValue(value, forKey: key)


    let aBool = true

    let key = "testBool"

    update(aBool, key: key)

    // cannot invoke 'update' with an argument list of type '(Bool, key:

    dictionary.updateValue(aBool, forKey: key)

    // works


My own function will get the error as shown in the comment part. But it
seams that Dictionary<String, AnyObject> has no issue. How to improving my

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20160525/ac8f8f05/attachment.html>

More information about the swift-users mailing list