Skip to content

Instantly share code, notes, and snippets.

@mauricio
Last active December 17, 2015 13:49
Show Gist options
  • Select an option

  • Save mauricio/5620057 to your computer and use it in GitHub Desktop.

Select an option

Save mauricio/5620057 to your computer and use it in GitHub Desktop.
object sample {
trait RandomGenerator {
def generate(): AnyVal
}
object IntGenerator extends RandomGenerator {
override def generate(): Int = 10
}
object ByteGenerator extends RandomGenerator {
override def generate(): Byte = 44
}
val int = IntGenerator.generate() //> int : Int = 10
val byte = ByteGenerator.generate() //> byte : Byte = 44
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment