CrazySynthax CrazySynthax - 3 months ago 14
Scala Question

Scala REPL: How to load specific package/class/object?

Let's say I have the following file:

package PackName

class Class1 {
def func11():
....
def func12():
...
}

class Class2 {
def func21():
...
def func22():
...
}


If I want to invoke func11 from Class 1 from REPL, I have to run REPL and call:


PackName.Class1.func11().


Do I have an option to load to REPL the class PackName.Class1 so I won't have to type "PackName.Class1" whenever I invoke a function of this class?

Answer
import PackName._  //import all members of the package
import PackName.Class1  // import a specific member
import PackName.{Class1, Class2} //import multiple members
Comments