Don't forget to also checkout my second blog containing articles to all other related ICT topics!!

Friday, May 25, 2012

Scala REPL is smart

Apparently the REPL is smart enough to figure out when you declare a function as it waits for the closing bracket to return. It auto-injects the | for you as you enter new lines. I read that there are a few use cases it can't handle very well yet like defining a class and companion object. Once I've tested this with current version of the REPL I will blog about these cases.
scala> def addTwo(x: Int) = {
     |    x + 2
     | }
addTwo: (x: Int)Int

scala> addTwo(5)
res5: Int = 7


No comments:

Post a Comment