Struct

定义

type Car {
    string name;
    uint price;
}

初始化

Car memory porsche = Car("Porsche", 79); // 必须与属性顺序一致
Car memory porsche = Car({price: 79, name: "Porsche"}); // 参数可以随意顺序
  • 赋值: porche.name = "my porche";

  • 取值: porche.name;

  • 删除: delete porche.name; // 只是将其重置为初始值, 相当于 porche.name = ""';

Last updated

Was this helpful?