tags:

views:

251

answers:

1

I heard recently some advice to "unimport an implicit conversion from Predef" - I presume that this means it is possible to unimport unwanted classes too:

import java.awt._
unimport java.awt.List

But this is not the syntax of an "unimport" (i.e. there is no such unimport keyword). What is the correct syntax?

+8  A: 

Use the import alias feature but rename the "unwanted class" to "_". Since "_" can not be accessed in Scala code as a classname, it hides the renamed class from unqualified access.

import java.awt.{List => _, _}
Walter Chang
Hmmm - this seems like a clumsy hack `:-(`
oxbow_lakes
No, it's not a hack, it's just overload on meanings of "_". If used alone in an import clause, it means everything. If used on the right side of an import rename, it means do not import.
Daniel