Skip to content

Instantly share code, notes, and snippets.

@gigiigig
Last active March 2, 2016 11:17
Show Gist options
  • Save gigiigig/d9df15de3a7d509f3c9e to your computer and use it in GitHub Desktop.
Save gigiigig/d9df15de3a7d509f3c9e to your computer and use it in GitHub Desktop.
Simple config example
trait Config {
val timeout: Int = 1
val interval: Int = 2
def wantToChangeThis: Int
}
object DefaultConfig extends Config {
val wantToChangeThis: Int = 34
}
class Foo(conf: Config) {
def run = {
println(conf.timeout)
println(conf.interval)
}
}
// This will be the defualt to use, but external caller can still override
// configs easily
object Foo extends Foo(DefaultConfig)
Foo.run
// 1
// 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment