title: How to reload a class or package in Scala REPL?
body: <p>I almost always have a Scala REPL session or two open, which makes it very easy to give Java or Scala classes a quick test.  But if I change a class and recompile it, the REPL continues with the old one loaded.  Is there a way to get it to reload the class, rather than having to restart the REPL?</p>
  
  <p>Just to give a concrete example, suppose we have the file Test.scala:</p>
  
  <pre><code>object Test { def hello = "Hello World" }
  </code></pre>
  
  <p>We compile it and start the REPL:</p>
  
  <pre><code>~/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&gt; Test.hello
  res0: java.lang.String = Hello World
  </code></pre>
  
  <p>Then we change the source file to</p>
  
  <pre><code>object Test {
    def hello = "Hello World"
    def goodbye = "Goodbye, Cruel World"
  }
  </code></pre>
  
  <p>but we can't use it:</p>
  
  <pre><code>scala&gt; Test.goodbye
  &lt;console&gt;:5: error: value goodbye is not a member of object Test
         Test.goodbye
              ^
  
  scala&gt; import Test;
  &lt;console&gt;:1: error: '.' expected but ';' found.
         import Test;
  </code></pre>