Skip to content

Instantly share code, notes, and snippets.

@benglass
Created June 30, 2016 19:41
Show Gist options
  • Save benglass/d0d95dd4baae706e3aaab59d1035510c to your computer and use it in GitHub Desktop.
Save benglass/d0d95dd4baae706e3aaab59d1035510c to your computer and use it in GitHub Desktop.
// Write some awesome Swift code, or import libraries like "Foundation",
// "Dispatch", or "Glibc"
// myProp as a required member variable with default of 0
struct MyStruct1 {
var myProp: Double = 0
}
let s1 = MyStruct1()
print("Target: \(s1.myProp)")
// myProp as a required member variable with NO Default
struct MyStruct2 {
var myProp: Double
}
let s2 = MyStruct2(myProp: 40)
// The following line would be illegal because there is no default myProp value and its required
// s2 = MyStruct2()
print("Target: \(s2.myProp)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment