Import Issue w/ Scala Libraries

Just getting started, and I can import Java libraries like "import java.util.Date", but when I try to import "scala.collection.mutable.Set" I get a compilation error of "value collection is not a member of package foobar.this.scala import scala.collection.mutable.Set" when I complie and run with Shift+F10.

Any ideas?

Thanks!

-ian


(Super simple) code follows:

package foobar.scala.test


import java.util.Date

import scala.collection.mutable.Set


object SandboxObject {

  def main(a: Array[String]) = {


    val tuple : Tuple3[Int, String, Date] = (9, "Joe Blow", new Date)

    Console.println("Date is " + tuple._3)


    val jetSet = Set("Boeing", "Airbus")

    jetSet += "Lear"

    Console.println(jetSet.contains("Cessna"))

  }

}



2 comments
Comment actions Permalink

Nevermind, just found out about "_root_"

For anyone else having similar issues, try:

import _root_.scala.collection.mutable.Set

0
Comment actions Permalink

Moreover, better to use:
import collection.mutable.Set
because package scala is implictly imported (like java.lang).
You have workaround to import mutable sets: type Se and press Ctrl+Alt+Space. After choosing scala.collection.mutable.Set appropriate import will be added automatically.

Best regards,
Alexander Podkhalyuzin.

0

Please sign in to leave a comment.