Instructor: James Riely
sbt to run tests
object o { val x = ... }
class c { ... }
console/:quit to get a REPL within sbtimport objects
import o._
// use x
val x = ...
// use x
:paste /Users/jriely/x.scala
// use x
x.scala in the SBT
directory. If you do, then SBT will try to compile it and
give you an error, since SBT requires files to contain only object and class declarations.
x.scala in my home directory (/Users/jriely/), or in /tmp/.
scala> class C { val x:Int = 1}
defined class C
scala> :javap -p -c -filter C
Compiled from "<console>"
public class C {
private final int x;
public int x();
Code:
0: aload_0
1: getfield #18 // Field x:I
4: ireturn
public C();
Code:
0: aload_0
1: invokespecial #24 // Method java/lang/Object."<init>":()V
4: aload_0
5: iconst_1
6: putfield #18 // Field x:I
9: return
}
scala> def x = 1
x: Int
scala> :javap -p -c -filter -
Compiled from "<console>"
public class {
public static MODULE$;
public static {};
Code:
0: new #2 // class
3: invokespecial #17 // Method "<init>":()V
6: return
public int x();
Code:
0: iconst_1
1: ireturn
public ();
Code:
0: aload_0
1: invokespecial #21 // Method java/lang/Object."<init>":()V
4: aload_0
5: putstatic #23 // Field MODULE$:L;
8: return
}
testOnly fp1tests
testOnly fp1tests -- -n fp1ex05
~testOnly fp1tests