How do I exclude/rename some classes from import in Scala?

ScalaScala 2.8

Scala Problem Overview


Language FAQ says

import scala.collection.mutable.{_, Map => _, Set => _}

should import all classes from package scala.collection.mutable, except Map and Set. But it gives me this error:

error: '}' expected but ',' found.
       import scala.collection.mutable.{_, Map => _, Set => _}

Is there still a way to do this?

Scala Solutions


Solution 1 - Scala

The _ has to be put at the end - not at the beginning:

Exclude Map and Set from the import

import scala.collection.mutable.{Map => _, Set => _, _}

Exclude Set and rename Map to ScalaMutableMap

import scala.collection.mutable.{Map=>ScalaMutableMap, Set => _, _}

See the detailed info in Scala Refererence, page 50, paragraph 4.7

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlexey RomanovView Question on Stackoverflow
Solution 1 - ScalaPatrickView Answer on Stackoverflow