所以这些都是在Scala中导入的有效方式。
scala> import scala.util.matching.Regex
import scala.util.matching.Regex
scala> import scala.util.matching._
import scala.util.matching._
scala> import scala.util.matching.{Regex, UnanchoredRegex}
import scala.util.matching.{Regex, UnanchoredRegex}
但是如何进行有效的分组完全导入?
scala> import scala.util.{control._, matching._}
<console>:1: error: '}' expected but '.' found.
import scala.util.{control._, matching._}
^
答案 0 :(得分:2)
您不能将import子表达式用作导入选择器。根据{{3}}
的规范导入表达式的最常见形式是导入选择器列表 {x1 =&gt; y1,...,xn =&gt; yn,_}
关于你的问题,最近的单行是:
scala> import scala.util._, control._, matching._
import scala.util._
import control._
import matching._