I have something like this:
trait AO extends A {
private var link: String = "AO"
//...
}
trait AR extends A {
private var link: String = "AR"
//...
}
object AO extends AO with Atr {
atr += link
}
object AR extends AR with Atr {
atr += link
}
trait Atr {
import scala.collection.mutable._
val atr: ListBuffer[String] = ListBuffer()
def echo() = {
for(f <- atr) println("attribute: " + f)
}
}
object TestF {
def main(args: Array[String]) {
AR.echo //not what I want!
AO.echo //not what I want!
echo() //doesn't show nothing...
}
}
How I can add such attributes in a ListBuffer, let say like atr
, and read them all at once like in the third line on TestF?