Ben Chuanlong Du's Blog

It is never too late to learn.

Use SnakeYaml in Scala

SnakeYAML

moultingyaml: Scala wrapper for SnakeYAML

Comment

If the input YAML doc has multiple formats, you can first load it as an Object and then use Object.isInstanceOf to check its type and use Object.asInstanceOf[SomeType] to cast it to the right type.

Use Scala With Picocli

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

It is easy to make mistakes due to type of parameters when use picocli in Scala. It is suggested that you

  1. Have all parameters prepared before using them.

  2. manually specify types …

sbt Plugins for Deployment

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

  1. sbt Assembly is recommended, generally speaking.

sbt-assembly

sbt-assembly creates a fat JAR, i.e., a single JAR file containing all class files from your code and libraries. By evolution, it also …

Null, None and Alike in Scala

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

Nil represents an emptry List of anything of zero length. It is not that it refers to nothing but it refers to List which has no contents. In other words, Nil …

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 …