Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

basic/advanced_type/enum #261

giscus[bot] bot announced in Comments
Jul 15, 2025 · 1 comments · 4 replies
Discussion options

basic/advanced_type/enum

简单、快速地学习 Zig,ziglang中文教程,zig中文教程

https://course.ziglang.cc/basic/advanced_type/enum

You must be logged in to vote

Replies: 1 comment 4 replies

Comment options

EnumLiteral部分用法是不是有错误 还是我理解错误?

我看官方好像是这样

const EnumLiteral: type = @Type(.enum_literal);
You must be logged in to vote
4 replies
Comment options

你是指枚举量的形式不同吗
这个没什么要求

Comment options

因为我是看着教程写的

const EnumLiteral: type = @Type(.EnumLiteral);

这种写法是无法编译通过的,报错信息:union 'builtin.Type' has no member named 'EnumLiteral',如果我改为@Type(.enum_literal),他就可以编译通过,因为enum_literal他是在std.builtin.Typeunion内的

也有可能是 我还是个小白 没理解教程里具体是什么意思 或许 再回头看的时候 就明白了

Comment options

我明白你的意思了,这里是教程的错误,EnumLiteral这个写法是旧版本的写法,新的版本对类型变量做了修改调整,zig-course这边忘记改这个了

Comment options

今天稍晚些我会纠正该问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /