One usually mixins trait this way:
trait Parent {
def f: Int = -1
}
class Child extends Parent {
override val f: Int = 1
}
Though, I accidentally found, that if we only use constants inside class body, we are able to achieve the same one more way:
class ChildBodyBefore extends {
override val f: Int = 1
} with Parent
Seems like these Child and ChildBodyBefore definitions works the same way:
new Child().f // 1
new ChildBodyBefore().f // 1
Why does second form even exist then? Do some particular reasons to use that extends { ... }
syntax exist?