Question: Question in Swift For problem 11, recall that when you tell Swift to print an object or a structure, it prints something that looks like
Question in Swift
For problem 11, recall that when you tell Swift to print an object or a structure, it prints something that looks like a call to an initializer. For example: struct Student { var name:String var age:int } var bob = Student(name:"Bob", age:16) print(bob) would print: Student(name:"Bob", age:16) 11. Consider the following code: struct Computer { var ram:Int var year Manufactured:Int init?(ram:Int, yearManufactured:Int) { if ram > 0 { self.ram = ram self.yearManufactured = yearManufactured } else { return nil } } } var computer1 = Computer(ram:2048, year Manufactured:2016) var computer2 = Computer(ram:0, yearManufactured:2018) if let comp = computer1 { print(comp) } if let comp = computer2 { print(comp) } What would be printed? Give a clear explanation justifying your answer step-by-step and using proper Swift terminology
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
