저는 거의 항상 스칼라 REPL 세션 또는 2 회의 오픈을 가지고 있습니다. 따라서 자바 또는 스칼라 클래스에 빠른 테스트를 쉽게 제공 할 수 있습니다. 그러나 클래스를 변경하고 다시 컴파일하면 REPL은로드 된 이전 클래스를 계속 사용합니다. REPL을 다시 시작하지 않고 클래스를 다시로드 할 수있는 방법이 있습니까?Scala REPL에서 클래스 또는 패키지를 다시로드하는 방법?
object Test { def hello = "Hello World" }
우리는 그것을 컴파일하고 REPL 시작 : 우리가
에 소스 파일을 변경 다음~/pkg/scala-2.8.0.Beta1-prerelease$ bin/scala
Welcome to Scala version 2.8.0.Beta1-prerelease
(Java HotSpot(TM) Server VM, Java 1.6.0_16).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Test.hello
res0: java.lang.String = Hello World
을
그냥 구체적인 예를 제공하기 위해, 우리는 파일 Test.scala 있다고 가정object Test {
def hello = "Hello World"
def goodbye = "Goodbye, Cruel World"
}
하지만 우리는 그것을 사용할 수 없습니다
scala> Test.goodbye
<console>:5: error: value goodbye is not a member of object Test
Test.goodbye
^
scala> import Test;
<console>:1: error: '.' expected but ';' found.
import Test;
REPL보다 워크 시트의 이점이 있습니다. – nafg