array
Table of Contents

数组

动态数组

动态长度:

uint[] a

length

push():添加成员

静态数组

固定长度数组:

uint[5] a

length

struct

  1. 通过数组来存储多个员工的信息

struct Employee { address id; uint salary; uint lastPayday; }

==要点==

  1. 创建新的struct对象不需要newEmployee(employee, salary, now)
  2. 在循环中,若要求的操作已完成,记得使用return退出,避免gas的无谓消耗
  3. var (empl, i)可用于接收两个返回值
  4. 自定义struct不能暴露出去,有function需要传入或者返回struct类型时需要设置为private
  5. 直接修改返回的变量改变的只是memory中的拷贝;通过index来修改变量的话,改变的就是storage中的值