3 ms·
Scala has something similar with "placeholder syntax for anonymous functions", where _.methodname() or _ + 1 is equivalent to x => x.methodname
by dangerbird2 6y ago
Scala has something similar with "placeholder syntax for anonymous functions", where
_.methodname()
or
_ + 1
is equivalent to
x => x.methodname()
or
x => x + 1
https://www.scala-lang.org/files/archive/spec/2.13/06-expressions.html#placeholder-syntax-for-anonymous-functions https://www.scala-lang.org/files/archive/spec/2.13/06-expres...
- raiph 6y agoFor single placeholders I prefer the look of either the `_` syntax or the alternative some PLs have of `.`. But otoh, Raku nicely stretches the approach to both zero and multiple placeholders: * The zero placeholder `.methodname` in Raku is the same as Scala's `_.methodname` * Any number of placeholders are allowed, so one can write eg `* + *` as an anonymous binary add function.