Elixir,num = [9],num被分配给' \ t'

时间:2016-03-23 17:06:17

标签: elixir

iex> num = [9]
'\t'

分配[9]的单个列表返回' \ t'。这是什么原因?

1 个答案:

答案 0 :(得分:6)

您可以使用i helper in IEx获取有关数据类型的更多信息:

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

如果您想检查原始表示,可以将char_lists: false传递给inspect

IO.inspect('abc', char_lists: false)
[97, 98, 99]