September 03, 2017

Expression trump statement

In programming, a statement is about changing states, while expression is all about the results. Which means. Expressions usually have fewer side effects on the states, especially outer states, and should be heavily used for functional programming.

Taking the following Scala(everything is an expression in Scala) codes as an example:

def abs(n: Int): Int =