Aleks Tamarkin created GROOVY-12220:
---------------------------------------
Summary: Pipeline Operator Support (possibly for groovy 6)
Key: GROOVY-12220
URL: https://issues.apache.org/jira/browse/GROOVY-12220
Project: Groovy
Issue Type: New Feature
Reporter: Aleks Tamarkin
Suggestion to add a functional pipline operator to Groovy
Groovy already prioritized writing code left to right with awesome improvements
over java like `someString.toURL()` instead of `new URL(someString)`
A pipleine operator could make this even more universal
Example implementation using xor `^`
{code:java}
class PipleineOperator {
static xor(Object self, Closure c) {
c(self)
}
}
class Foo { static foo(v) { v + 3 } }
Closure example = {
def x = { it ** 2 + it }
4 ^ x ^ { it / 2 } ^ (Foo.&foo)
}
use(PipleineOperator) {
example() // 4 -> 4 * 4 + 4 = 20 -> 20 / 2 = 10 -> 10 + 3 = 13
}{code}
Example in F#
https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/functions/#pipelines
Thanks in advance for taking a look
--
This message was sent by Atlassian Jira
(v8.20.10#820010)