Dart基础语言 — symbol、enum、comments
Dart基础语言 — symbol、enum、comments
符号 Symbol
Dart语言的标识符,在反射中用的很普及,特别是很多发布包都是混淆后的。
import 'dart:mirrors'; Symbol libraryName = new Symbol('dart.core'); MirrorSystem mirrorSystem = currentMirrorSystem(); LibraryMirror libMirror = mirrorSystem.findLibrary(libraryName); libMirror.declarations.forEach((s, d) => print('$s - $d'));
枚举 Enum
适合用在常量定义,类型比较很方便。
enum Status { none, running, stopped, paused }Status.values.forEach((it) => print('$it - index: ${it.index}'));
注释 Comments
单行注释
// Symbol libraryName = new Symbol('dart.core');
多行注释
/* * Symbol * Symbol libraryName = new Symbol('dart.core'); MirrorSystem mirrorSystem = currentMirrorSystem(); LibraryMirror libMirror = mirrorSystem.findLibrary(libraryName); libMirror.declarations.forEach((s, d) => print('$s - $d')); */
文档注释
/// `main` 函数 /// /// 符号 /// 枚举 /// void main() { ... }
PDF文档整理:
赞 (0)