Using a Trait name as shorthand for any class that mixes it in

Suppose Parental is defined as a trait. Is it OK to declare a variable like this:
var clients : ListBuffer[Parental]
to mean that clients is a ListBuffer of objects of any class that mixes in Parental?
If not, is there a way to express that?

Works - and declares your intent.

Do you mean to have a var ListBuffer instead of a val? ListBuffer is mutable. Will you need to replace the entire instance?

1 Like

Thanks. I did say var because it is mutable.

On further thought, yes, clients can be a val because in my application it can be immutable even if the arraybuffer itself is mutable. Thanks for drawing attention to that point.