用于查找的Swift 3.1 Key-Only Dictionary

时间:2017-04-03 18:26:53

标签: swift dictionary swift3

我想知道Swift3.1中有一些字典或其他数据类型的天气,我可以使用它来创建仅供查找的表。

例如: 我想检查我是否已经在O(N)中收到了一个特定的字符串。

当然,我可以这样做:

let dict = ["hello":true, "world":"true"]

然后检查我的字典是否包含inputString:

dict[input] != nil ? print("got it already") : print("new String")

但我想摆脱我必须添加的布尔值。

0 个答案:

没有答案