I saw several scala code examples where several lines of code are used as a block of code without curly braces, for example:
x match { case a:Int => val b = 1 val c = b +3 println("hello!") c case _ => 5 }
same with some very long functions that use implicit form pairs:
a.map { implicit x =>
Unlike:
a.map { implicit x => {
I saw a lot of documentation / frequently asked questions about the fact that several lines of code should always be surrounded by curly braces, but could not find an explanation for these exceptions. I would like to understand or have a good intuition so that I do not like magic.
source share