Jesús Gabriel y Galán
9/2/2008 6:00:00 AM
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.