3 ms·
Feature request for pipeline operator in Ruby: https://bugs.ruby-lang.org/issues/15799 https://bugs.ruby-lang.org/issues/15799 See also: https://mamememo.blog
by omoikane 5y ago
Feature request for pipeline operator in Ruby:
https://bugs.ruby-lang.org/issues/15799 https://bugs.ruby-lang.org/issues/15799
See also:
https://mamememo.blogspot.com/2019/06/a-brief-history-of-pipeline-operator.html https://mamememo.blogspot.com/2019/06/a-brief-history-of-pip...
https://mametter.hatenablog.com/entry/2019/06/15/192311 https://mametter.hatenablog.com/entry/2019/06/15/192311
- leifg 5y agoIf I understand the Ruby pipeline operator it's essentially an alias of the dot. The example in the feature tracker is: ``` 1.. |> take 10 |> map {|e| e2} |> (x) ``` which is equivalent to ``` (1...).take(10).map{|e| e2} ``` So in order to use it you still need extensions on every single object. The only reason that looks nice is because in this example you continuously call methods on lists that return a list. You can't add `my_custom_list_operation(list_input)` in between.
- dragonwriter 5y agoIt's worth noting that that version of pipeline operator was abandoned, while there are still (some newer) open feature requests for a more traditional functional-style pipeline operator.
- tylerscott 5y agoyield_self is an less elegant way to achieve basically the same thing as |>.
- WallowingInShit 5y agoSame thing, but for JavaScript: https://github.com/tc39/proposal-pipeline-operator https://github.com/tc39/proposal-pipeline-operator Going forward, the pipe operator is going to be showing up in many new languages. I've used elixir a lot, and the pipe operator is a genius piece of syntactic sugar.