Suppose c can be Updatable or Drawable or both. If it's both, I want to handle Updatable first.
Given this code:
case c: Updatable => c.update()
case c: Drawable => c.draw()
Has one problem: it only evaluates one of the choices. Sometimes, c can be both so I need to run both of these.
I know there's | mechanism that looks like this:
case c @ (_: Updatable | _: Drawable) => c.update(); c.draw()
The problem here is that I can't call both update and draw because it's an |.
I think I'm looking for something like this, but doesn't compile:
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 I could open it up and write isInstacenOf, but I'd prefer a pattern match if it's even possible.