iex> num = [9]
'\t'
Run Code Online (Sandbox Code Playgroud)
分配单个[9]列表会返回'\ t'.这是什么原因?
iex> i [9]
Term
'\t'
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
[9]
Reference modules
List
Run Code Online (Sandbox Code Playgroud)
如果要检查原始表示,可以传递char_lists: false给inspect:
IO.inspect('abc', char_lists: false)
[97, 98, 99]
Run Code Online (Sandbox Code Playgroud)