Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there goto statement in Ruby?

Tags:

ruby

goto

Is there a way to start at a specified line, like a goto statement?

like image 540
gpwu Avatar asked Oct 28 '09 02:10

gpwu


People also ask

Is there goto in Golang?

In this article, you will learn about how to use goto statement in Golang. Goto statement is found in many programming languages. It is altered the normal sequence of program execution by transferring control to some other part of the program. The goto statement is also known as the unconditional jump statement.

How do you implement a goto statement?

Syntax of goto Statementgoto label; ... .. ... ... .. ... label: statement; The label is an identifier. When the goto statement is encountered, the control of the program jumps to label: and starts executing the code.

What is goto statement?

A goto statement causes your program to unconditionally transfer control to the statement that is associated with the label specified on the goto statement.

Is goto a looping statement?

The goto statement can be used to alter the flow of control in a program. Although the goto statement can be used to create loops with finite repetition times, use of other loop structures such as for, while, and do while is recommended.


2 Answers

First, it would be statement, not a command. Second, see ruby-goto. Third, note

Category: Library/Evil

like image 80
Sinan Ünür Avatar answered Oct 21 '22 13:10

Sinan Ünür


There is the ruby command line switch -x.

 -x[directory]  Tells Ruby that the script is embedded in a message.
                Leading garbage will be discarded until the first that
                starts with “#!” and contains the string, “ruby”.  Any
                meaningful switches on that line will applied.  The end of
                script must be specified with either EOF, ^D (control-D),
                ^Z (control-Z), or reserved word __END__.  If the direc‐
                tory name is specified, Ruby will switch to that directory
                before executing script.

BTW, I'm pretty sure ruby-goto was, umm, a joke. I don't believe the download link has ever worked. Or am I just supposed to point people to it and keep quiet? I never know...

I liked Ryan's next line after announcing ruby-goto:

Stay tuned for the next evil module... ruby-malloc! Have a nice day.

Ryan is clearly a genius.

like image 33
DigitalRoss Avatar answered Oct 21 '22 12:10

DigitalRoss