Skip to content

Instantly share code, notes, and snippets.

@aoiroaoino
Created September 27, 2014 07:51
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 aoiroaoino/ddc3d7dc901f3cef95ed to your computer and use it in GitHub Desktop.
Save aoiroaoino/ddc3d7dc901f3cef95ed to your computer and use it in GitHub Desktop.
trait User {
val name: String
}
trait Password {
val key: Option[String]
}
//-------------------------------
trait NoPassword extends Password {
val key = None
}
//-------------------------------
trait PublicUser {
self: User with Password =>
}
trait PrivateUser extends NoPassword {
self: User with Password =>
}
//-------------------------------
val publicUser = new PublicUser with User with Password {
val name = "Hoge"
val key = Some("aaa")
}
val privateUser = new PrivateUser with User with NoPassword {
val name = "Huga"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment