Skip to content

Instantly share code, notes, and snippets.

@mikekavouras
Last active May 5, 2016 18:48
Show Gist options
  • Save mikekavouras/6dc1743b461a333e6b00ee55697385f2 to your computer and use it in GitHub Desktop.
Save mikekavouras/6dc1743b461a333e6b00ee55697385f2 to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
class global {
class func getUserId() -> String {
return "10"
}
}
class AccountData {
var data: Dictionary<String,AnyObject> = Dictionary<String,AnyObject>()
var auth_info: Dictionary<String,AnyObject> = Dictionary<String,AnyObject>()
var auth_type: Dictionary<String,AnyObject> = Dictionary<String,AnyObject>()
var emailType: Dictionary<String,AnyObject> = Dictionary<String,AnyObject>()
var contactType: Dictionary<String,AnyObject> = Dictionary<String,AnyObject>()
}
public func += <KeyType, ValueType> (inout left: Dictionary<KeyType, ValueType>, right: (KeyType, ValueType)){
left.updateValue(right.1, forKey: right.0)
}
var accountData = AccountData()
accountData.data += ("UserId", global.getUserId() as! AnyObject) //.getUserId() returns the uID as a string: this does not work, the compiler does not recognize the overloaded operator
//accountData.data += ("UserId", "69" as! AnyObject) //this code works as expected
print(accountData.data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment