# 智能合约-15.枚举 **Published by:** [Murraya](https://paragraph.com/@murraya/) **Published on:** 2022-05-08 **URL:** https://paragraph.com/@murraya/15 ## Content 枚举// SPDX-License-Identifier: MIT pragma solidity ^0.8.7; contract Enum { enum Status { Node, Pedding, Shipped, Completed, Rejected, Canceled } Status public status; struct Order { address buyer; Status status } Order[] public orders; function get() view returns (Status) { return status; } // 设置枚举类型 function set(Status _status) external { status = _status; } // 指定特定的枚举类型 function ship() external { status = Status.Shipped; } // 恢复为默认值 function reset() external { delete status; } } ## Publication Information - [Murraya](https://paragraph.com/@murraya/): Publication homepage - [All Posts](https://paragraph.com/@murraya/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@murraya): Subscribe to updates