How can I define package-wide default imports? I want to define a package p
such that
import p._
is equivalent to
import scala.util.Try
import scala.collection.mutable.Queue
Follow the pattern used in scala/package.scala to make some of the standard collection available without imports. It involves a package object
with a type
and a val
for each import:
package object p {
type Try[A] = scala.util.Try[A]
val Try = scala.util.Try
type Queue[A] = scala.collection.mutable.Queue[A]
val Queue = scala.collection.mutable.Queue
}
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