Pregunta

What is proper usage of stdout() function from package io in dart? I wrote such a script:

#import('dart:io');
void main() {
  print("Hello World");
  stdout();
}

and I get following output:

firen@firen-VirtualBox:~/Downloads$ ./dart/dart-sdk/bin/dart ./dart/workspace/test/text.dart Hello world Unhandled exception: Object is not closure 0. Function: '::main' url: '/home/firen/Downloads/dart/workspace/test/text.dart' line:6 col:7

¿Fue útil?

Solución

import 'dart:io';
void main() {
     String s = "Hello World";
     stdout.write(s.charCodes());
}

stdout is a property of type OutputStream rather than method, which is why you get the "Object is not a closure" error when you try to call stdout();

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top