Skip to content

Instantly share code, notes, and snippets.

@nubbel
Last active September 7, 2016 12:35
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 nubbel/09f488f19e2912b65ca910cb5e08f6e5 to your computer and use it in GitHub Desktop.
Save nubbel/09f488f19e2912b65ca910cb5e08f6e5 to your computer and use it in GitHub Desktop.
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