Scala lambda style (x) => {...} vs { (x) => ... } -
i'm new scala , reading sample code using rescala. in code, appears author uses 2 styles define lambdas:
{ x => println(x) }
(x => { println(x) })
i assume these 2 styles semantically equivalent. think second style allows easy addition of additional statements in lambda body.
is correct? way more "idiomatic"? interesting whether {}
opens new lexical scope (like in c) or not.
i assume these 2 styles semantically equivalent.
yes
however think second style allows easy addition of additional statements in lambda body.
no. or, rather, yes, first style.
which way more "idiomatic"?
this opinion-based. opinions vary.
it interesting whether
{}
opens new lexical scope (like in c) or not.
yes do.
Comments
Post a Comment