Let's say I have a Scala project with a bunch of case classes under package com.example.a.b.c
. I want to import all these classes into a package com.example.c
(which contains a few more non-conflicting case classes) so that anywhere else in my project, I only need to import com.example.c._
to use every case class both from com.example.c
and com.example.a.b.c
.
How can I do that?
There is discussion of adding an export mechanism which would do what you want, but it's not clear whether that will happen.
In any case, for now the only way is to
So for example,
package bar
case class Foo(i: Int) {}
would need to be mimicked in another package with
package object baz {
type Foo = bar.Foo
val Foo = bar.Foo
}
When faced with this, people usually just settle for an extra import or two.
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