关键字参考 (Keyword Reference)

以下是 Zig 语言的保留关键字列表:

  • addrspace
  • align
  • allowzero
  • and
  • anyframe
  • anytype
  • asm
  • async
  • await
  • break
  • callconv
  • catch
  • comptime
  • const
  • continue
  • defer
  • else
  • enum
  • errdefer
  • error
  • export
  • extern
  • fn
  • for
  • if
  • inline
  • linksection
  • noalias
  • nosuspend
  • opaque
  • or
  • orelse
  • packed
  • pub
  • resume
  • return
  • struct
  • suspend
  • switch
  • test
  • threadlocal
  • try
  • union
  • unreachable
  • usingnamespace
  • var
  • volatile
  • while

这些关键字不能用作标识符。如果必须使用关键字作为标识符,可以使用 @"" 语法转义,例如 @"\x69\x66"@"if”`(尽管通常不建议这样做)。