InterviewSolution
Saved Bookmarks
| 1. |
Consider the following code snippet |
|
Answer» DUMP function is used to print the content of the object For eg: class Person { let name: STRING let cars: [String]? init(name:String, cars: [String]?) { self.name = name self.cars = cars } }let allPerson = [Person(name: "P1", cars: ["P1_C1", "P1_C2"]), Person(name: "P2", cars: ["P2_C1", "P2_C2"])] Output: ▿ 2 elements ▿ App.Person #0 - name: "P1" ▿ cars: Optional(["P1_C1", "P1_C2"]) ▿ some: 2 elements - "P1_C1" - "P1_C2" ▿ App.Person #1 - name: "P2" ▿ cars: Optional(["P2_C1", "P2_C2"]) ▿ some: 2 elements - "P2_C1" - "P2_C2" //As seen, dump() OUTPUTS the whole class hierarchy, while print() simply outputs the class name. |
|