Say I have a trait with a property a:
trait TheTrait {
def a: String
}
I have a class with a property a too in which I want to instantiate that trait anonymously:
class TheClass {
val a = "abc"
val traitInstance = new TheTrait {
def a = a // I want to assign it to the `a` of TheClass here
// but this way it doesn't work
}
}
How can I achieve this?
either
TheClass.this.a, or give an alias tothisinTheClass(calling itselfis customary)