原文标题:《 Solidity 极简入门: 5. 引用类型, array, struct 》
Original author: 0xA&NBsp;
I have been reworking solidity to consolidate the details and also writing a "Solidity Minimalism Primer" for nerds (find another tutorial for programmers) with weekly updates of 1-3 sessions.
All code open source in making: github.com/AmazingAng/WTFSolidity
In this lecture we will look at two important variable types in solidity: arrays and structs.
Arrays are a common variable type for solidity, used to store a set of data (integers, bytes, addresses, etc.). There are two types of arrays: fixed length arrays and variable length arrays:
Fixed length array:Specify the length of the array at declaration time. Declare with the format T[k], where T is the type of the element and k is the length, for example:

Variable length array:The length of the array is not specified in the declaration. Declare with the format T[], where T is the type of the element, for example (bytes in particular are arrays, but do not add []) :

In Solidity there are some rules for creating arrays:
Memory variable-length arrays can be created using the new operator, but the length must be declared and cannot be changed. Example:

数组字面常数是写作表达式形式的数组,并且不会立即赋值给变量,例如 [uint(1),2,3](需要声明第一个元素的类型,不然默认用存储空间最小的类型)如果创建的是 dynamic array,你需要一个一个元素的赋值。

Length: The array has a length member that contains the number of elements. The length of the memory array is fixed after creation.
Push (): variable length array and Bytes with & have spent push() You can add a 0 element to the end of the array.
push(x): Variable-length arrays and bytes have push(x) You can add an X element to the end of the array.
Pop: Variable-length arrays and bytes have pop Member that removes the last element of the array.
Solidity supports defining new types in the form of constructs. To create a structure:

There are two ways to assign a value to a structure:

In this lecture we cover the basic uses of arrays and structs in solidity. Next we will look at hash tables in Solidity - mapping.
The original link
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia
