#scala #traits
a trait is very similar to what we have abstract classes in Java.
If you want to change selection, open document below and click on "Move attachment"
Scala Traits consists of two methods isEqual and isNotEqual. Here, we have not given any implementation for isEqual where as another method has its implementation. Child classes extending a trait can give implementation for the un-implemented methods. So <span>a trait is very similar to what we have abstract classes in Java. Below is a complete example to show the concept of traits:
trait Equal {
def isEqual(x: Any): Boolean
def isNotEqual(x: Any): Boolean = !isEqual(x)
}
class Point(xc: Int, yc: Int) e Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details