|
|
|
|
|
by pmontra
2747 days ago
|
|
I quote one of the examples "https://api.github.com/repos/ruby/ruby".pipe do
URI.parse
Net::HTTP.get
JSON.parse.fetch("stargazers_count")
yield_self { |n| "Ruby has #{n} stars" }
Kernel.puts
end
#=> Ruby has 15115 stars
Not having to type the |> like in Elixir is two shift keys less, which is good. I'm not sure about readability, because one has to spot the .pipe at the beginning of the block, but it shouldn't be a problem.Now, if we only had pattern matching with the exact syntax of Elixir and not some monstrosity I saw around in proposals and other languages... |
|
Check out this other proof of concept demonstrating ES6 style object destructuring in Ruby:
https://github.com/lendingHome/destruct
I think this same type of concept could be applied to port Elixir style pattern matching as well e.g.