Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method pipe syntax to Dart to allow easy chaining/piping of expressions to in-scope methods #18485

Closed
kevmoo opened this issue Apr 28, 2014 · 4 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@kevmoo
Copy link
Member

kevmoo commented Apr 28, 2014

Anything of the form

g(f(expression))

Can be written as

expression |> f() |> g()

Basically, the expression on the left side of |> is passed as the first parameter of the function on the right of |>.

What about multiple arguments? Named arguments?

If you had function

int count(int a, int b, int c, {int d}) { ... }

You can call it as

count(1, 2, 3, d: 4);

or

1 |> count(2, 3, d: 4);

The "|>" symbol salad is open for discussion, of course.

@kevmoo
Copy link
Member Author

kevmoo commented Apr 28, 2014

Related blog post with a few examples: http://work.j832.com/2014/04/method-piping-dart-syntax-proposal.html

@gbracha
Copy link
Contributor

gbracha commented Apr 28, 2014

This is not unreasonable. We'll have to discuss it in TC52. I suspect it will be awhile before it makes its way to the top of the agenda. We have smallish matters to propose before this - like async/await perhaps.


Set owner to @gbracha.
Added Accepted label.

@DartBot
Copy link

DartBot commented Apr 28, 2014

This comment was originally written by @vicb


relates to https://code.google.com/p/dart/issues/detail?id=16900

@kevmoo
Copy link
Member Author

kevmoo commented Apr 28, 2014

Giving credit to the first person to file this...


Added Duplicate label.
Marked as being merged into #16900.

@kevmoo kevmoo added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Apr 28, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants