在io包中正确使用函数stdout

编程入门 行业动态 更新时间:2024-10-24 01:56:05
本文介绍了在io包中正确使用函数stdout的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

本文发布于:2023-11-26 20:17:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1635045.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:函数   包中   正确   io   stdout

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!