dart中package io的stdout()函数的正确用法是什么? 我写了一个这样的脚本:
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(); },我得到以下输出:
firen @ firen-VirtualBox:〜/下载$ ./dart/dart-sdk/bin/dart ./dart/workspace/test/text.dart Hello world未处理的异常:对象不是闭包 0.功能:':: main'url:'/home/firen/Downloads/dart/workspace/test/text.dart'line:6 col:7
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
推荐答案
import 'dart:io'; void main() { String s = "Hello World"; stdout.write(s.charCodes()); }
stdout是 OutputStream 而不是方法,这是为什么你得到对象不是一个闭包错误,当你尝试调用stdout();
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();
更多推荐
在io包中正确使用函数stdout
发布评论