Ben Chuanlong Du's Blog

It is never too late to learn.

Line Continuation in Scala

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Scala does not have a line continuation character. It infers a semicolon always when:

  1. an expression can end

  2. The following (not whitespace) line begins not with a token that can start …

Recursion in Scala

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Tricks to Write Tail Recursive Calls

  1. A useful trick to write tail recursive function is to include the result to return as a parameter. If the result to return is a …

Issues in Scala

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

2.12

  1. Avoid using view of collections.

2.11

  1. Iterator ++ non lazy, might cause stack overflow issues. This issue has been fixed in 2.12.

  2. Stream.filterNot, not lazy, might cause …

Unit Test for Scala

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. Both ScalaTest and spec2 are good unit testing frameworks. ScalaTest is more flexible is recommended.

ScalaTest

only assert is supported.

assert(expr1 === expr2, optional_msg)

The JUnit methods assertTrue, assertEquals and assertArrayEquals …

Speed Up sbt in China

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

Currently sbt uses https by default. However, the Great Firewall of China makes https visits to websites out of China slow.

Proxy

If you have access to proxy server, it is …

Scala Dependencies for SBT

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

  1. Joda Time

    "joda-time" % "joda-time" % "2.9.9"
    
  2. Scala XML Support

    "org.scala-lang.modules" %% "scala-xml" % "1.0.6"
    
  3. Scala Parser Combinators

    "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
    
  4. Scala Swing

    "org.scala-lang …