如何创建退出消息 [英] How to create an exit message

查看:33
本文介绍了如何创建退出消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个单行函数调用可以退出程序并显示一条消息?我知道在 Perl 中它很简单:

Is there a one line function call that quits the program and displays a message? I know in Perl it's as simple as:

die("Message goes here")

我厌倦了输入:

puts "Message goes here"
exit

推荐答案

abort 函数可以做到这一点.例如:

The abort function does this. For example:

abort("Message goes here")

注意:abort 消息将写入 STDERR,而 puts 将写入 STDOUT.

Note: the abort message will be written to STDERR as opposed to puts which will write to STDOUT.

这篇关于如何创建退出消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆