此問題與Enum.reverse/1
函數沒有直接關係。你可以通過傳遞整數的列表IO.write/1
重現同樣的事情:
iex(5)> IO.write([8,7,6,5,4,3,2,1])
^H^G^F^E^D^C^B^A:ok
這裏發生的事情是,IO.write/1
正在接收整數的列表,並把它作爲「字符列表」。使用單引號時可以創建char列表,如'foo'
。使用給了我們很多的細節:
iex(22)> i('foo')
Term
'foo'
Data type
List
Description
This is a list of integers that is printed as a sequence of characters
delimited by single quotes because all the integers in it represent valid
ASCII characters. Conventionally, such lists of integers are referred to as
"char lists" (more precisely, a char list is a list of Unicode codepoints,
and ASCII is a subset of Unicode).
Raw representation
[102, 111, 111]
Reference modules
List
我想,這些字符是由這將導致聲音效果和「笑臉」窗口古怪的解釋。
編輯:入門文檔也是非常有用的:http://elixir-lang.org/getting-started/binaries-strings-and-char-lists.html#utf-8-and-unicode
不是爲了你的利益@MakeWebSocketsGreatAgain但對於其他人的利益誰可能會發現這樣一個問題:https://github.com/elixir-lang/elixir/wiki/FAQ(項目4)。 –