2

I used the following import statement in hope to disable the class of Option, but looks like Option is still availabe in the scope. How to disable it?

scala> import scala.{Option=>_,Either=>_,_}
import scala.{Option=>_, Either=>_, _}

scala>  val b:Option[Int]=Some(1)           
b: Option[Int] = Some(1)

scala> 
Daniel Wu
  • 5,853
  • 12
  • 42
  • 93
  • 1
    In general this is the proper syntax for unimport (works in other cases). My guess would be that `Option` is always imported by predef. [In this answer](http://stackoverflow.com/questions/7634015/scala-predef-unimport) they mention an experimental option to disable predef (`-Yno-predef`) but I can't find documentation on this switch. Does it solve your problem? – bluenote10 Apr 28 '14 at 13:34
  • 1
    Your syntax instructs runtime to exclude Option and Either from importing action, but it is too late: once class is imported it is in scope and Option, just like some other core things is imported by Predef. Solution, as @bluenote suggested, is to disable Predef importing, which will bring down initial importing of that core things, including Option -- though it would not allow you to unload things, you will get clean room scope. – om-nom-nom Apr 28 '14 at 13:53
  • The comments are incorrect. http://www.artima.com/pins1ed/packages-and-imports.html#i1384274725-1 – som-snytt Apr 28 '14 at 16:15
  • @som-snytt well, they are incorrect in fix part: you still cannot unimport something from the scope, especially with such syntax – om-nom-nom Apr 28 '14 at 20:21

0 Answers0