int, double, etc.nullval num = 3.14 val fun = Math.ceil _ fun(num) // prints 4
(x : Double) => x * x
3.14
"Hello".toUpper() doesn't change "Hello"
but returns a new string "HELLO"val are immutable
val num = 3.14 num = 1.42 // Error
(1 to 10).map((x : Double) => x * x)
strings.sort(new Comparator<String>() {
public void compare(String a, String b) {
return a.length() - b.length();
}
});

bin subdirectory
of that directory to your PATH. Here are the directions for
Linux, Mac OS X, or Cygwin under Windows.
cd ; tar xvfz
downloaddir/scala-version.tar.gz ~/.bashrc file:
export SCALA_HOME=/home/username/scala-version export PATH=$SCALA_HOME/bin:$PATH
If you choose to run Windows without Cygwin, you will have to go through the hell of the Windows environment editor. Don't blame Scala for this. Keep these points in mind:
installdir\scala-version\bin and a
semicolon before the existing PATH.PATH? Look here. Under
Vista, you need to be administrator to do this. scala. What do you get? scala, you should have received a prompt of
the Scala interpreter. Type 3 * 2. (Don't type the period, and
hit ENTER after each input line.) What do you get?res0. What do you get?val a = 3 * 4. What do you get?a. What do you get? a = 9. What do you get?res0 = 9. What do you get?val triple = (x : Int) => 3 * x. What do you get?
triple(5). What do you get?
HINT: These “What do you get” exercises are a lot more effective when you and your buddy first discuss whar you think you'll get. “Form a hypothesis” is an essential part of the learning path.
triple. What do you get?triple in Scala?5 in Scala?1 to 10. What do you get?(1 to 10).map(triple). What do you get? Why? val?