Answer the question
In order to leave comments, you need to log in
What will be in the dictionary when you assign an object to it through a key?
I don't know if I phrased the question correctly. I'm just learning.
There is this code:
class List {
let name: String
var movies: [String] = []
init(name: String) {
self.name = name
}
}
class User {
var lists: [String: List] = [:]
func addList(_ list: List) {
lists[list.name] = list
}
}
let jane = User()
var actionList = List(name: "Action")
jane.addList(actionList)
jane.lists["Action"]?.movies.append("Rambo")
jane.lists["Action"]?.movies.append("Terminator")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question