[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how can I exit with a message in ruby?

Lex Williams

9/2/2008 5:43:00 AM

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-....

3 Answers

Jesús Gabriel y Galán

9/2/2008 6:00:00 AM

0

On Tue, Sep 2, 2008 at 7:43 AM, Lex Williams <etaern@yahoo.com> 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.

Bill Kelly

9/2/2008 6:10:00 AM

0


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

abort "bye..."



Hope this helps,

Bill


Lex Williams

9/2/2008 7:26:00 AM

0

Bill Kelly wrote:
> From: "Lex Williams" <etaern@yahoo.com>
>>
>> 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-....