Multiple packages definition

后端 未结 2 1650
谎友^
谎友^ 2020-12-14 05:45

While browsing the source code of the Scala API, I met this package definition in scala/tags/R_2_8_0_final/src/library/scala/util/parsing/combinator/syntactical/StdTokenPars

2条回答
  •  轮回少年
    2020-12-14 06:28

    This is basically the same as

    package scala.util.parsing.combinator.syntactical
    
    import scala.util.parsing._
    import scala.util.parsing.combinator._
    
    ...
    

    So by "stacking" the packages the way you wrote you can get super-packages in scope. See also these answers.

    [Update] Here is a new article written by Martin Odersky about this topic: http://www.artima.com/scalazine/articles/chained_package_clauses_in_scala.html

提交回复
热议问题