aa8y
aa8y

Reputation: 3942

How to do grouped full imports in Scala?

So these are all valid way to import in 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}

But how to do a valid grouped full import?

scala> import scala.util.{control._, matching._}
<console>:1: error: '}' expected but '.' found.
import scala.util.{control._, matching._}
                          ^

Upvotes: 0

Views: 186

Answers (1)

4e6
4e6

Reputation: 10776

You can't use import sub-expression as an import selector. According to specification on Import Clauses

The most general form of an import expression is a list of import selectors { x1 => y1,…,xn => yn, _ }

Regarding your question, the closest one-liner is:

scala> import scala.util._, control._, matching._
import scala.util._
import control._
import matching._

Upvotes: 2

Related Questions