“Kamus Swift” Kode Jawaban

Buat Kamus Swift

var someDict:[String:Int] = ["One":1, "Two":2, "Three":3] // creates dictionary
var someVar = someDict["One"] // accesses the value of key "One"

print("The value of key = One is \(someVar)")
sej

Kamus Swift

// dictionary with keys and values of different data types
var numbers = [1: "One", 2: "Two", 3: "Three"]
print(numbers)
SAMER SAEID

Buat kamus di Swift

var capitalCity = ["Nepal": "Kathmandu", "Italy": "Rome", "England": "London"]
print(capitalCity)
SAMER SAEID

Cara Mendapatkan Daftar Nilai dari Kunci Khusus di Objek Array di Swift

import Foundation

let strings = [
    "one",
    "two",
    "three"
]

let ints = strings.map { (string) -> Int in
    return string.count
}
Homeless Hare

Jawaban yang mirip dengan “Kamus Swift”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya