Suppose it ccould be Updatableeither Drawableor both. If so, I want to process first Updatable.
Given this code:
case c: Updatable => c.update()
case c: Drawable => c.draw()
There is one problem: it evaluates only one of the options. Sometimes it ccan be at the same time, so I need to run both of these files.
I know a mechanism |that looks like this:
case c @ (_: Updatable | _: Drawable) => c.update(); c.draw()
The problem here is that I cannot name both updateand drawbecause he |.
I think I'm looking for something like this, but not compiling:
case c @ (_: Updatable & _: Drawable) => c.update(); c.draw()
case c: Updatable => c.update()
case c: Drawable => c.draw()
Is there such a thing? I know that I can open it and write isInstacenOf, but I would prefer a pattern match, even if it is possible.