Last active
October 23, 2018 18:39
-
-
Save andreaslydemann/d28ea2828eb99d2413e004436bce7ffa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Processor { | |
var modelNumber: Int | |
init() { | |
self.modelNumber = 21043 | |
} | |
} | |
struct Computer { | |
var processor: Processor? | |
init(processor: Processor?) { | |
self.processor = processor | |
} | |
} | |
let myComputer = Computer(processor: Processor()) | |
if let modelNumber = myComputer.processor?.modelNumber { | |
print("The model number of the processor is \(modelNumber)") | |
} else { | |
print("Seems like you need a processor for your computer") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment