Scala

Scala

Made by DeepSource

Lambda can be converted to expression bodied lambda SC-R1063

Anti-pattern
Major

Lambdas are like anonymous functions and can be passed as arguments for higher-order functions such as .map() and look like:

val square = (x: Int) => {
  x * x
}

However, if your lambda's body has a single statement, you can write it as:

val square = (x: Int) => x * x

This is a short hand syntax and is succinct.

References: