2025年5月11日
摘要: lua中并没有 switch 语句,我们该怎么实现一个简单的 switch 呢 switch (c) { case 'a': printf("aaa\n"); break; case 'b': printf("bbb\n"); break; case 'c': printf("ccc\n"); br 阅读全文
posted @ 2025-05-11 20:30 Dylaris 阅读(249) 评论(0) 推荐(0)
摘要: lua中并没有枚举类型,我们该如何实现一个简单的枚举呢 enum { APPLE = 101, ORANGE, GRAPE, PEACH }; 上面是对应的c代码,接下来我们用lua实现类似的效果 核心的代码如下: local function create_enum(tbl, start_idx) 阅读全文
posted @ 2025-05-11 20:14 Dylaris 阅读(199) 评论(0) 推荐(0)