I often would like to use |
with keywords. Is there a technical / grammar issue that prevents Elixir from writing it using the shortcut notation?
tail = [3, 4]
list = [1, 2 | tail]
# => [1, 2, 3, 4]
tail = [c: 3, d: 4]
list = [a: 1, b: 2 | tail]
# => ** (CompileError) iex:7: misplaced operator |/2
I have to write using the long form, or use ++
which does not look as nice and that many would believe (apparently mistakenly! thanks hauleth and benwilson512) that would be less efficient
list = [{:a, 1}, {b: 2} | tail] # => ok
list = [a: 1, b: 2] ++ tail # => ok, might appear not as efficient
Edit: tweaked my question after being corrected about performance