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?
Scala provides package objects as a convenient container shared across an entire package. Package objects can contain arbitrary definitions, not just variable and method definitions. For instance, they are frequently used to hold package-wide type aliases and implicit conversions.
Import in Scala Importing packages in Scala is more flexible than in other languages. We can place import statements anywhere in the code and even hide or rename members of packages when you import them. Note: Users can either import the package as a whole or some of its member methods, classes, etc.
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 => _, _}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With