How to create an exit message

前端 未结 4 1832
刺人心
刺人心 2020-12-12 13:14

Is there a one line function call that quits the program and displays a message? I know in Perl it\'s as simple as:

die(\"Message goes here\")
4条回答
  •  孤街浪徒
    2020-12-12 13:38

    I've never heard of such a function, but it would be trivial enough to implement...

    def die(msg)
      puts msg
      exit
    end
    

    Then, if this is defined in some .rb file that you include in all your scripts, you are golden.... just because it's not built in doesn't mean you can't do it yourself ;-)

提交回复
热议问题