var declared site and take effect as new
- Value Type
- Reference types
Make the difference and new
Press new built-in functions 指定类型
allocate memory length of zero value, returning a pointer, does not care about the type of internal configuration and initialization method.
The reference types 必须使用make函数创建
,
the compiler will convert to make 目标类型
a dedicated 创建函数
(or instructions),
in order to ensure the completion of all the memory allocation and related properties have been initialized.
Of course, new functions can also be a reference type allocate memory, but it is not complete creation. A dictionary (map), for example, required memory it allocated only dictionary type itself (the actual package is a pointer), and does not allocate memory key-value store, there is no initialization hash buckets and other internal properties, so it does not work.
相比数字、数组等类型,引用类型拥有更复杂的存储结构。除分配内存外,它们还须初始化一系列属性,
诸如指针、长度,甚至包括哈希分布、数据队列等。