Several SO posts like this deal with the same error message, but none of those solutions work. It appears like this could be a case of a misleading error message.
The code below generates an "Ambiguous reference to member map" error for the map call.
Anyone know why?
func saveUser(user: User) {
var userDicts = masterDict["users"] as! [[String:AnyObject]]
let newDict = user.getDict()
// Replace matching element with <newDict>
let replaced = false
masterDict["users"] = userDicts.map {
if ($0["id"] as String! == user.getId()) {
replaced = true
return newDict
} else {
return $0 as [String:AnyObject]
}
}
// If no match found, means must add new user
if (!replaced) {
userDicts.append(newDict)
}
}