如果两者都在消息后添加换行符,则dart中的print()和stdout.writeln()有什么区别?

时间:2018-10-01 20:10:53

标签: dart

这是我简单的飞镖代码。

import 'dart:io';

main(){
    print("Hello World");
    stdout.writeln("Another Hello World");
}

输出:

Hello World   //Prints newline by default. 
Another Hello World    //Also print newline after this.

如果两个函数在打印后都打印换行符,那么两者之间有什么区别。

1 个答案:

答案 0 :(得分:2)

在DartVM上,行为是相同的。但是,当Dart代码在浏览器中运行时,您将无法使用stdoutdart:io library不能在基于浏览器的应用程序中使用。 print是核心库的一部分,可以在任何地方使用。

print can be overriden with Zone(在VM上也有一点区别)。