关键字

Last updated: ... / Reads: 39 Edit

下表列出了 Dart 语言特别处理的关键字。

abstract2 else import2 show1
as2 enum in static2
assert export2 interface2 super
async1 extends is switch
await3 extension2 late2 sync1
base2 external2 library2 this
break factory2 mixin2 throw
case false new true
catch final (variable) null try
class final (class)2 on1 typedef2
const finally operator2 var
continue for part2 void
covariant2 Function2 required2 when
default get2 rethrow while
deferred2 hide1 return with
do if sealed2 yield3
dynamic2 implements2 set2

避免使用这些词作为标识符。但是,如果需要,用上标标记的关键字可以是标识符:

  • 带有上标1的单词是上下文关键字,仅在特定位置才有意义。它们在任何地方都是有效的标识符。
  • 带有上标 2 的单词是内置标识符。这些关键字在大多数地方都是有效的标识符,但它们不能用作类或类型名称,也不能用作导入前缀。
  • 带有上标3的单词是与异步支持相关的有限保留字。您不能在任何标有 、 或 的函数体中使用 或 作为标识符。 await yield async async* sync*

表中的所有其他字都是保留字,不能是标识符。


Comments

Make a comment