say I have the following code:
package my
class Foo
class Bar extends Foo
object Chooser {
val isFoo = true
}
I import Foo
as:
import my.{Foo => MyClass}
I want to be able to do something like:
If Chooser.isFoo
, then:
import my.{Foo => MyClass}
else:
import my.{Bar => MyClass}
I have used Foo
in my code as something like this:
object MyObj {
val a = new MyClass
// ...
}
Are there any hidden features of Scala that let me use Bar
in place of Foo
without modifying the code of MyObj
at all. Also what would be the best way to design such code in future so that such extensions are easy?