Last active
September 7, 2016 12:35
-
-
Save nubbel/09f488f19e2912b65ca910cb5e08f6e5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Manager { | |
final class Configuration { | |
var name: String = "default" | |
var timeout: Double = 500 | |
} | |
private let configuration: Configuration | |
var name: String { | |
return configuration.name | |
} | |
var timeout: Double { | |
return configuration.timeout | |
} | |
init(configure: ((Configuration) -> Void)? = nil) { | |
let configuration = Configuration() | |
configure?(configuration) | |
self.configuration = configuration | |
} | |
} | |
let defaultManager = Manager() | |
defaultManager.name | |
defaultManager.timeout | |
let customManager = Manager { | |
$0.name = "custom" | |
$0.timeout = 2000 | |
} | |
customManager.name | |
customManager.timeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment