Skip to content

Instantly share code, notes, and snippets.

@duemunk
Last active August 29, 2015 14:05
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 duemunk/4f186467e0fac1924d42 to your computer and use it in GitHub Desktop.
Save duemunk/4f186467e0fac1924d42 to your computer and use it in GitHub Desktop.
Chaining syntax
struct Foo {
private let privateObject: PrivateObjectType
private init(_ privateObject: PrivateObjectType) {
self.privateObject = privateObject
}
}
extension Foo { // Static methods
static func bar() -> Foo {
// Do stuff
let privateObject = PrivateObjectType()
let foo = Foo(privateObject)
return foo
}
}
extension Foo { // Regular methods matching static
func bar() -> Foo {
// Do stuff
let privateObject = PrivateObjectType()
let foo = Foo(privateObject)
return foo
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment