Both CSplit and MapCanvT are subtypes of Scala Swing Component. So type CanvNode is always a subtype of Component. I haven't got to grips with the functional stuff of Scala collections yet like fold. Is there any way to reduce this code (aside from putting the match in a function) and get rid of those matches?
type CanvNode = Either[CSplit, MapCanvT]
class CSplit(var s1: CanvNode, var s2: CanvNode) extends SplitPane
{
topComponent = s1 match { case Left (s) => s; case Right (s) => s}
bottomComponent = s2 match { case Left (s) => s; case Right (s) => s}
The above compiles. Ideally I'd just write:
type CanvNode = Either[CSplit, MapCanvT]
class CSplit(var s1: CanvNode, var s2: CanvNode) extends SplitPane
{
topComponent = s1
bottomComponent = s2
but that won't compile.