Skip to content

Instantly share code, notes, and snippets.

@4lex1v
Created June 24, 2014 15:34
Show Gist options
  • Save 4lex1v/5df4bfd2fd100551f74d to your computer and use it in GitHub Desktop.
Save 4lex1v/5df4bfd2fd100551f74d to your computer and use it in GitHub Desktop.
Small silly cake
trait Service {
def host: String
def port: Int
}
trait GoogleServiceModule extends Service {
val host = "google.com"
val port = 80
}
trait BingServiceModule extends Service {
val host = "bing.com"
val port = 80
}
trait FooModule {
type bar <: BarLike
trait BarLike { _: Service =>
def connect = println {
s"Connecting to $host:$port"
}
}
}
object EndOfAll
extends FooModule {
object bar
extends BarLike
with BingServiceModule // or with GoogleServiceModule
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment