scala,import test._ ; import test.{ClassA,ClassB}

在scala中,*不是通配符,下斜杠“_”才是通配符。因此当使用某个package所有的类时,直接使用:import test._;使用某几个时,直接使用:import test.{ClassA,ClassB}

 

  • Do you want to use the whole package? Use import me.test._.
  • Do you want to cherry-pick only some parts of the package? Use import me.test.{ ClassOne, classTwo }.

 

参考:https://softwareengineering.stackexchange.com/questions/194686/why-does-scala-use-the-operator-for-package-import-instead-of-as-in-java

 

posted @ 2018-07-17 20:54  脚本小娃子  阅读(267)  评论(0编辑  收藏  举报