Skip to content

Latest commit

 

History

History
28 lines (24 loc) · 1.68 KB

File metadata and controls

28 lines (24 loc) · 1.68 KB

关键字

下面这个表格列举了Dart中相关的关键字:

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

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

  • 上标1的单词是上下文关键字,只有在特定的地方才有意义。它们到处都是有效的标识符。
  • 上标2的单词是内置标识符。为了简化将JavaScript代码移植到Dart的任务,这些关键字在大多数地方都是有效的标识符,但它们不能用作类名或类型名,也不能用作导入前缀。
  • 上标3的单词是更新的、有限的保留单词,与Dart 1.0版本之后添加的异步支持相关。不能在任何使用async、async或sync标记的函数体中使用wait或yield作为标识符。

表中的所有其他单词都是保留单词,不能作为标识符也不能作为属性名。