fewerBraces: allow braceless lambdas as argument to an infix operator #17730
sjrd
started this conversation in
Feature Requests
Replies: 1 comment
-
In this case we can simply replace the braces by parens. object Test:
def main(args: Array[String]): Unit =
val source = new EventSource(5, 8, 10)
source --> ( x =>
val y = x * x
println(y)
) Arguably that's clearer than the (illegal) version without parens. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The following example reproduces a very common idiom in Laminar:
If we try to write the lambda using the braceless syntax of
fewerBraces
, as follows:we get an obscure error message:
Because of this limitation, typical Laminar code becomes very ugly if we try to use
fewerBraces
on them. Here is a diff coming from one of my personal projects:I suggest that the above syntax be allowed, i.e., that an infix operator may introduce a braceless lambda, just like a dotted call like
.map
.Beta Was this translation helpful? Give feedback.
All reactions