Skip to content

Instantly share code, notes, and snippets.

@Kdan
Last active July 6, 2020 13:29
Show Gist options
  • Select an option

  • Save Kdan/0c1d7df50c31e228948c8a1808922e8f to your computer and use it in GitHub Desktop.

Select an option

Save Kdan/0c1d7df50c31e228948c8a1808922e8f to your computer and use it in GitHub Desktop.
class A {
/// A `Bool` indicating if we have the answer to the universe.
private(set) var hasAnswer = false
/// The instance of `BType` we are using to check if we have the answer.
private let b: BType
init(b: BType) {
self.b = b
}
/// Checks if we have the answer to the universe and updates the `hasAnswer` property.
func checkAnswer() {
hasAnswer = b.validateAnswer()
}
}
class B: BType {
/// The `CType` used to get the number.
private let c: CType
init(c: CType) {
self.c = c
}
/// Validates if `c` has the answer.
func validateAnswer() -> Bool {
c.number == 42
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment