Skip to content

Instantly share code, notes, and snippets.

@Reflejo
Last active October 11, 2015 01:36
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 Reflejo/21b9fe4be65a69f9d8f9 to your computer and use it in GitHub Desktop.
Save Reflejo/21b9fe4be65a69f9d8f9 to your computer and use it in GitHub Desktop.
protocol SomeProtocol {
var a: Int { get }
}
struct SomeStruct: SomeProtocol {
var a = 0
}
class SomeClass {
var value: SomeProtocol = SomeStruct() {
didSet { print("Setter called.") }
}
func doSomething() {
print("About to do something")
_ = self.value.a
print("Did something")
}
}
SomeClass().doSomething()
// Output:
//
// About to do something
// Setter called.
// Did something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment