Installed Scala...the journey begins..

September 26, 2011 . . Comments
Tags: tech scala


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 http://www.scala-lang.org/downloads/distrib/files/scala-2.9.1.final-installer.jar
After it is downloaded, execute the below command
java -jar scala-2.9.1.final-installer.jar
I installed scala at this location
~/scala
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 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala>
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...
 

Comments Section

Feel free to comment on the post but keep it clean and on topic.

blog comments powered by Disqus