Swift:如何在字符串表达式中打印出字典键的值?
发布时间:2020-12-14 04:34:39 所属栏目:百科 来源:网络整理
导读:参见英文答案 escape dictionary key double quotes when doing println dictionary item in Swift????????????????????????????????????5个 出于某种原因,我只是不能使这个表达式工作: let expandedBio: DictionaryString,AnyObject = ["name":"Saurabh","
参见英文答案 >
escape dictionary key double quotes when doing println dictionary item in Swift????????????????????????????????????5个
出于某种原因,我只是不能使这个表达式工作: let expandedBio: Dictionary<String,AnyObject> = ["name":"Saurabh","profession":"developer","language":"java","employed": true] if let employed : AnyObject = expandedBio["employed"] { println("(expandedBio["name"]) is not available") } 如何输出println语句?我收到了错误 Unexpected "" character error in string interpolation 我该怎么做? 解决方法
在当前版本的Swift中,您必须先将值放在自己的常量/变量中,然后使用它.
if let employed : AnyObject = expandedBio["employed"] { let t = expandedBio["name"] println("(t) is not available") } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |