September 26, 2011

Installed Scala...the journey begins..

Scala has caught my interest lately. It has been due on my learning list.
Also - Play Framework (which I'm currently using) has got awesome Scala support (I see lot of answers and questions of Play and Scala on the Google groups).
I've read the primer..looks very interesting. Now to do code something concrete.

To download Scala (latest as of today) and install on Mac (Snow Leopard 10.8) is quite easy:
curl -O
After it is downloaded, execute the below command
java -jar
I installed scala at this location
Add the executable to the path.
vim .profile
# append or add to the PATH variable ~/scala/bin
export PATH=$PATH:~/scala/bin
(or to the bash profile i.e. vim .bash_profile)
Open a terminal and type scala and you should see the below output
Welcome to Scala version (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

Try the below example:
scala> val numbers = Map(1 -> "one", 2 -> "two")
numbers: scala.collection.immutable.Map[Int,java.lang.String] = Map(1 -> one, 2 -> two)

scala> numbers.get(2)
res0: Option[java.lang.String] = Some(two)

scala> numbers.get(3)
res1: Option[java.lang.String] = None
To quit the interpreter, just type quit.
To begin -  here is the awesome link on Learning Scala for beginners.
I also installed Scala Eclipse IDE - a plugin for Scala development on Eclipse.

Until next time...

No comments: