开发者

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

开发者 https://www.devze.com 2022-12-31 15:10 出处:网络
Language FAQ says import scala.collection.mutable.{_, Map => _, Set => _} should import all classes from package scala.collection.mut开发者_如何学JAVAable, except Map and Set. But it gives m

Language FAQ says

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

should import all classes from package scala.collection.mut开发者_如何学JAVAable, 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消