Skip to content

Commit 42ecc84

Browse files
committed
Expand pipelines on right-hand side of |>, closes #12070
1 parent c457405 commit 42ecc84

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/elixir/lib/kernel.ex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4115,7 +4115,11 @@ defmodule Kernel do
41154115
41164116
"""
41174117
defmacro left |> right do
4118-
Macro.pipe(left, right, 0)
4118+
fun = fn {x, pos}, acc ->
4119+
Macro.pipe(acc, x, pos)
4120+
end
4121+
4122+
:lists.foldl(fun, left, Macro.unpipe(right))
41194123
end
41204124

41214125
@doc """

lib/elixir/test/elixir/kernel_test.exs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,10 @@ defmodule KernelTest do
12331233
assert [1] |> (&hd(&1)).() == 1
12341234
end
12351235

1236+
test "reverse associativity" do
1237+
assert [1, [2], 3] |> (List.flatten() |> Enum.map(&(&1 * 2))) == [2, 4, 6]
1238+
end
1239+
12361240
defp twice(a), do: a * 2
12371241

12381242
defp local(list) do

0 commit comments

Comments
 (0)