Hacker News new | ask | show | jobs
by dangerbird2 1985 days 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-expres...
1 comments

For 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.