Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the arrow in an import statement do?

Tags:

scala

I've found the the following import in some scala:

import Predef.{println => _, _}

What does the => do?

like image 318
Finkelson Avatar asked Sep 30 '15 22:09

Finkelson


1 Answers

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

like image 102
Arne Claassen Avatar answered Nov 02 '22 23:11

Arne Claassen