I have a package object with some implicit classes in a package say x
. Lets call it being in a file x.scala
. I have two subpackages x.a
and x.b
. I need to use the same implicit classes in the two subpackages as well.
As of now I have made package objects for the two subpackages in: a.scala
and b.scala
and replicated the code for the implicit class in the two objects.
There must be a way this can be done in a better manner. Can I somehow use the package object of x
package and use it in the two subpackages?
Declare packages a and b like this:
package x
package a
and
package x
package b
This is sorta like saying package x.a
followed by import x
. Then you should have access to all of your implicit stuff in x
.
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