@kyanny's blog

My life. Opinions are my own.

はじめての Scala

ほんとに、ただインストールしてみただけ。

$ sudo port install scala
$ scala
kyanny-macbook:Desktop kyanny$ scala
Picked up _JAVA_OPTIONS: -Duser.language=en
Welcome to Scala version 2.7.5.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_13).
Type in expressions to have them evaluated.
Type :help for more information.

scala> var i:String = "google" 
i: String = google

scala> i
res0: String = google

scala> val j:String = "Yahoo!"
j: String = Yahoo!

scala> j   
res1: String = Yahoo!

scala> i = 'livedoor'
<console>:1: error: unexpected quote after symbol
       i = 'livedoor'
           ^

scala> i = "livedoor"
i: String = livedoor

scala> i
res3: String = livedoor

scala> j = "ebay" 
<console>:5: error: reassignment to val
       j = "ebay"
         ^

scala> def sqrt(n:Int):Int = n*n
sqrt: (Int)Int

scala> sqrt(10)
res5: Int = 100

なんか、ひさしぶりに楽しかった。なんでだろう。 Scala で何かやろうとか、勉強しようとか、一切考えてないから気楽だったのかな。