Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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