Initialization of dictionaries in Swift
Forums:
//Dictionary<String, String>
let languages = ["ru" : "russian", "en" : "english"]
//Dictionary<Int, String>
let numbers: Dictionary<Int, String> = [1: "one", 2: "two", 3: "three"]
//Dictionary<Int, Employee>
let employees = [
1: Employee(firstName: "Pavlov", lastName: "Anton"),
2: Employee(firstName: "Kirienko", lastName: "Elena")]
- Log in to post comments