Skip to content

Goto

The last jump statement is the goto statement. It is an unstructured jump, allowing you to jump anywhere in the code. This is a statement you need to be aware of, but not one that should be used.

Why?

The following comic demonstrates the hazards of using the goto statement.

The dangers of using goto, from http://xcd.com/292

Image from XKCD, licensed under Creative Commons Attribution-NonCommercial 2.5 (CC-BY-NC 2.5)

Seriously, the goto statement isn’t something that you are ever likely to need. It breaks the sequence of code, and makes it much harder to reads. If you ever think you need it, there will be other better ways to achieve your goals.