How can I exit with a message in ruby?

hi guys !

does ruby have a die method ? or is it there a method that displays a
string before exiting ?

On Tue, Sep 2, 2008 at 7:43 AM, Lex W. [email protected] 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.

From: “Lex W.” [email protected]

does ruby have a die method ? or is it there a method that displays a
string before exiting ?

abort “bye…”

Hope this helps,

Bill

Bill K. wrote:

From: “Lex W.” [email protected]

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 .