Scala importing a file in all files of a package

Posted by Core_Dumped on Stack Overflow See other posts from Stack Overflow or by Core_Dumped
Published on 2013-11-12T09:49:59Z Indexed on 2013/11/12 9:52 UTC
Read the original article Hit count: 164

Filed under:
|

I need to use an implicit ordering that has been defined in an object in a file

abc

in the following way:

object abc{
implicit def localTimeOrdering: Ordering[LocalDate] = Ordering.fromLessThan(_.isBefore(_))
}

So, I make a package object

xyz

inside a file 'package.scala' that in turn is in the package 'xyz' that has files in which I need the implicit ordering to be applicable. I write something like this:

package object xyz{
import abc._
}

It does not seem to work. If I manually write the implicit definition statement inside the package object, it works perfectly. What is the correct way to import the object (abc) such that all of its objects/classes/definitions can be used in my entire package 'xyz' ?

© Stack Overflow or respective owner

Related posts about scala

Related posts about import