我在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
上述用法之间有什么区别|
,为什么iex将它们显示为[[1], [2]]
和[1 | 2]
?