You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Daniel Sun (JIRA)" <ji...@apache.org> on 2019/02/17 12:13:00 UTC
[jira] [Updated] (GROOVY-8997) Add DGM `then` to transform nested
method calls to method call chain
[ https://issues.apache.org/jira/browse/GROOVY-8997?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Sun updated GROOVY-8997:
-------------------------------
Description:
Here is a sample to transform nested method calls to method call chain:
{code:java}
// nested method calls
c(
b(
3,
a()
),
2
)
{code}
{code:java}
// method call chain
a().then {
b(3, it)
}. then {
c(it, 2)
}
{code}
BTW, I even want to introduce a new syntax, which was discussed in dev mailing list:
{code:java}
// the following code is equal to the above code
a() |> b(3, _) |> c(_, 2) // _ represents the former method call result, and |> is like a big arrow representing the direction of data flow
{code}
was:
Here is a sample to transform nested method calls to method call chain:
{code:java}
// nested method calls
c(
b(
3,
a()
),
2
)
{code}
{code:java}
// method call chain
a().then {
b(3, it)
}. then {
c(it, 2)
}
{code}
BTW, I even want to introduce a new syntax, which was discussed in dev mailing list:
{code:java}
// the following code is equal to the above code
a() |> b(3, _) |> c(_, 2) // _ represents the former method call result, and |> is like a big arrow
{code}
> Add DGM `then` to transform nested method calls to method call chain
> --------------------------------------------------------------------
>
> Key: GROOVY-8997
> URL: https://issues.apache.org/jira/browse/GROOVY-8997
> Project: Groovy
> Issue Type: Improvement
> Reporter: Daniel Sun
> Assignee: Daniel Sun
> Priority: Major
>
> Here is a sample to transform nested method calls to method call chain:
> {code:java}
> // nested method calls
> c(
> b(
> 3,
> a()
> ),
> 2
> )
> {code}
> {code:java}
> // method call chain
> a().then {
> b(3, it)
> }. then {
> c(it, 2)
> }
> {code}
> BTW, I even want to introduce a new syntax, which was discussed in dev mailing list:
> {code:java}
> // the following code is equal to the above code
> a() |> b(3, _) |> c(_, 2) // _ represents the former method call result, and |> is like a big arrow representing the direction of data flow
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)