how can I exit with a message in ruby?

Discussion in 'Ruby' started by Lex Williams, Sep 2, 2008.

  1. Lex Williams

    Lex Williams Guest

    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/.
     
    Lex Williams, Sep 2, 2008
    #1
    1. Advertising

  2. 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.
     
    Jesús Gabriel y Galán, Sep 2, 2008
    #2
    1. Advertising

  3. Lex Williams

    Bill Kelly Guest

    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
     
    Bill Kelly, Sep 2, 2008
    #3
  4. Lex Williams

    Lex Williams Guest

    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/.
     
    Lex Williams, Sep 2, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2FuZHk=?=

    Code to Exit Web App and Exit Internet Explorer

    =?Utf-8?B?U2FuZHk=?=, Aug 3, 2005, in forum: ASP .Net
    Replies:
    7
    Views:
    7,975
    =?Utf-8?B?U2FuZHk=?=
    Aug 5, 2005
  2. Joe Smith
    Replies:
    4
    Views:
    66,084
    sandeep1976
    Nov 8, 2006
  3. Replies:
    2
    Views:
    492
    Jeff Epler
    May 31, 2005
  4. QQ
    Replies:
    5
    Views:
    548
    Jonathan Adams
    May 10, 2005
  5. Yujo
    Replies:
    2
    Views:
    438
    Gabriel Genellina
    Apr 10, 2007
Loading...

Share This Page