import语句中的箭头有什么作用?

时间:2015-09-30 22:55:55

标签: scala

我在某些import中找到了以下scala

import Predef.{println => _, _}

=>做了什么?

1 个答案:

答案 0 :(得分:5)

Generally => in an import allows you to alias an existing name into an alternate name:

import scala.{Int => i32}

This would allow you to use i32 in place of Int

Further, importing _ imports all symbols into the current namespaces.

Now, aliasing a name into _, however does the opposite, i.e. excludes it from the import:

import Predef.{println => _, _}

means

*Import all from Predef except println