For example, this:
val queue = new BasicIntQueue with Doubling with Incrementing with Filtering
queue.put(1)
println(queue.get())
will print:
Filtering
Incrementing
Doubling
put
4
As for me it would be more readable if it executed from left to right, in the order I wrote operations.
Because it follows the same pattern as inheritance. Imagine that you had something like this:
class BasicIntQueue
class Doubling extends BasicIntQueue
class Incrementing extends Doubling
class Filtering extends Incrementing
val queue = new Filtering
You'll get the same results as you saw: Filtering
gets executed first, then pass on to Incrementing
, then Doubling
and finally BasicIntQueue
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With