Last active
August 29, 2015 14:05
-
-
Save duemunk/4f186467e0fac1924d42 to your computer and use it in GitHub Desktop.
Chaining syntax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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