Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If both adds newline after message, What is the difference between print() and stdout.writeln() in dart?

Tags:

dart

here is my simple dart code.

import 'dart:io';

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

output:

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

If both functions print a newline after printing, then what is the difference between both of them.

like image 329
Jay Tillu Avatar asked Oct 29 '25 19:10

Jay Tillu


1 Answers

On the DartVM the behaviours are the same. But when Dart code runs in browser you cannot use stdout. dart:io library can not be used in Browser-based applications. print been part of the core library it can be used everywhere.

A little difference (also on VM) is that print can be overriden with Zone.

like image 71
Alexandre Ardhuin Avatar answered Nov 01 '25 16:11

Alexandre Ardhuin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!