Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > how can I exit with a message in ruby?

Reply
Thread Tools

how can I exit with a message in ruby?

 
 
Lex Williams
Guest
Posts: n/a
 
      09-02-2008
hi guys !

does ruby have a die method ? or is it there a method that displays a
string before exiting ?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Jesús Gabriel y Galán
Guest
Posts: n/a
 
      09-02-2008
On Tue, Sep 2, 2008 at 7:43 AM, Lex Williams <> wrote:
> hi guys !
>
> does ruby have a die method ? or is it there a method that displays a
> string before exiting ?


Kernel#at_exit

You can register handlers that get executed when the program exits.

at_exit {puts "Dying"}
puts "In the program"

You can build your own method to print, such as:

module Kernel
def print_at_exit str
at_exit {print str}
end
end

print_at_exit "goodbye"

Jesus.

 
Reply With Quote
 
 
 
 
Bill Kelly
Guest
Posts: n/a
 
      09-02-2008

From: "Lex Williams" <>
>
> does ruby have a die method ? or is it there a method that displays a
> string before exiting ?


abort "bye..."



Hope this helps,

Bill


 
Reply With Quote
 
Lex Williams
Guest
Posts: n/a
 
      09-02-2008
Bill Kelly wrote:
> From: "Lex Williams" <>
>>
>> does ruby have a die method ? or is it there a method that displays a
>> string before exiting ?

>
> abort "bye..."
>
>
>
> Hope this helps,
>
> Bill


Thanks Bill , just what I was looking for .
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Can I get the exit code "n" passed to sys.exit(n) ? Yujo Python 2 04-10-2007 08:35 PM
Exit code of a batch (using exit /B) Joe Smith Java 4 11-08-2006 12:25 PM
Code to Exit Web App and Exit Internet Explorer =?Utf-8?B?U2FuZHk=?= ASP .Net 7 08-05-2005 01:55 AM
exit after process exit ajikoe@gmail.com Python 2 05-31-2005 08:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57