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:
String)'
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
code?
Zhaoxin
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users