Ruby Tip #1 – abort

For some time I have been studying and practicing the Ruby language. Thus, to register my discoveries I’ll post them as Ruby tips in this blog.

The first tip is about writing to stderr and quitting your script when something goes wrong. It’s a common practice for UNIX hackers do this.

In Ruby there is a lot of ways for doing something and this is one of the few examples.

So, instead of doing this:

STDERR.puts "Something gone wrong"
exit(1)

we can do this:

abort "Something gone wrong"

To know more about the abort method, click here.

That’s it. ;-)


This entry was posted in English, Programação, Ruby and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>