1
是否有可能通過關鍵 & 值訪問單一Dictionary
條目的key
和value
,不 & ?鍵/值對的字典斯威夫特
在這個例子中:
let rockyPlanets: Dictionary<String, Int> = [
// Alphabetical order
"Earth": 3, "Mars": 4, "Mercury": 1, "Venus": 2
]
for eachPlanet in rockyPlanets {
println("\(eachPlanet.0) is at position \(eachPlanet.1)")
}
我怎樣才能通過鍵或值(非指數)以這種方式訪問鍵/值:
for eachPlanet in rockyPlanets {
println("\(eachPlanet.key) is at position \(eachPlanet.value)")
}
簡單和優雅 – SwiftArchitect 2014-11-09 05:32:46