views:

958

answers:

2

I'm using IntelliJ IDEA with the Scala plugin. If I reference HashMap in code, and then use Alt-Enter to add the import, the package gets imported as:

_root_.scala.collection.immutable.HashMap

What's the root part of this? It seems to work with and without it.

+7  A: 

It has to do scala imports being relative - _root_ gives you a way to specify an absolute package name. See the Scala Wiki

Kevin Hakanson
+1  A: 

You would only need it if inside your current package you had a nested package scala.collection.immutable containing HashMap. This would be preferred by a relative import without the _root_ part.

Edit: That was not quite right, the problems start already if you have a scala package either as an ancestor or nested in the current package.

starblue

related questions