Skip to content

Instantly share code, notes, and snippets.

@vialyx
Last active October 7, 2018 16:42
Show Gist options
  • Save vialyx/9673e2e9d85a39ae4d36b16cba2d78e7 to your computer and use it in GitHub Desktop.
Save vialyx/9673e2e9d85a39ae4d36b16cba2d78e7 to your computer and use it in GitHub Desktop.
struct PropertyStruct {
static var storedTypeProperty = "1"
static var computedTypeProperty: Double {
return 10.0
}
}
print("struct type property: \(PropertyStruct.storedTypeProperty)")
PropertyStruct.storedTypeProperty = "2"
print("struct type property: \(PropertyStruct.storedTypeProperty)")
enum PropertyEnum {
static var storedTypeProperty = "1"
static var computedTypeProperty: Double {
return 10.0
}
}
print("enum type property: \(PropertyEnum.storedTypeProperty)")
PropertyEnum.storedTypeProperty = "2"
print("enum type property: \(PropertyEnum.storedTypeProperty)")
class PropertyClass {
static var storedTypeProperty = "1"
static var computedTypeProperty: Double {
return 10.0
}
class var overrideableComputedTypeProperty: Double {
return 10.0
}
}
print("class type property: \(PropertyClass.storedTypeProperty)")
PropertyClass.storedTypeProperty = "2"
print("class type property: \(PropertyClass.storedTypeProperty)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment