Last active
December 20, 2015 05:08
-
-
Save deserat/6075439 to your computer and use it in GitHub Desktop.
Traits can be implemented and extended on the fly with initialized values. This includes JAVA Interfaces.....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Similarity { | |
def isSimilar(x: Any): Boolean | |
def isNotSimilar(x: Any): Boolean = !isSimilar(x) | |
} | |
val b = 25 | |
val foo = new Similarity() { | |
var x: Int = b | |
def isSimilar(x: Any): Boolean = { | |
true | |
} | |
} | |
foo.x | |
// 25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment