1

I was doing this in iex:

Interactive Elixir (1.3.0-dev) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> a = [1]
[1]
iex(2)> b = [a | [2]]
[[1], 2]
iex(3)> [head | tail] = b
[[1], 2]
iex(4)> head
[1]
iex(5)> tail
[2]
iex(6)> n = [1]
[1]
iex(7)> o = [1 | 2]
[1 | 2]
iex(8)> [h | t] = o
[1 | 2]
iex(9)> h
1
iex(10)> t
2

What is/is there the/a difference between the above usages of |, and why is iex displaying them as [[1], [2]] and [1 | 2]?

Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
Geo
  • 93,257
  • 117
  • 344
  • 520

0 Answers0