将符号转换为字符串 [英] Converting a Symbol into a String
本文介绍了将符号转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法将符号转换为字符串?
Is there a way to covert a Symbol into a String?
例如,VariableMirror返回Symbols而不是字符串。有没有办法将一个Symbol转换成一个String,所以我可以打印一个类的所有变量名。
For instance, a VariableMirror returns Symbols instead of Strings. Is there a way to convert a Symbol into a String, so I can print all the variable names of a class?
推荐答案
import 'dart:mirrors';
void main() {
var sym = new Symbol('test');
print(MirrorSystem.getName(sym));
}
此输出:
This outputs:
test
这篇关于将符号转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文