Skip to content

Instantly share code, notes, and snippets.

@andreaslydemann
Last active October 23, 2018 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreaslydemann/d28ea2828eb99d2413e004436bce7ffa to your computer and use it in GitHub Desktop.
Save andreaslydemann/d28ea2828eb99d2413e004436bce7ffa to your computer and use it in GitHub Desktop.
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