Skip to content

Instantly share code, notes, and snippets.

@milseman
Created February 7, 2018 18:29
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 milseman/d8360121856f4780bd5172cc94f96251 to your computer and use it in GitHub Desktop.
Save milseman/d8360121856f4780bd5172cc94f96251 to your computer and use it in GitHub Desktop.
struct S1 {
var stored: UInt?
init(_ x: UInt) {
if x > 42 {
self.init(_big: x)
return
}
self.stored = x // <--- error: 'self' used before 'self.init' call or assignment to 'self'
}
init(_big x: UInt) {
self.stored = x
}
}
struct S2 {
var stored: UInt?
init(_ x: UInt) {
if x > 42 {
self.init(_big: x)
return
}
self.init(_small: x)
}
init(_big x: UInt) {
self.stored = x
}
init(_small x: UInt) {
self.stored = x
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment