How to "go to" in a RUBY script . .

Hi,
Can someone tell me how to implement a “go to” kind of statement in
RUBY–GOTO, like in DOS or Windows scripts? If I do an “if” statement
for certain files in a directory, I want to “go to” other parts of the
program to execute certain stuff, kind of like a subroutine. In fact,
does RUBY have subroutines, or, does one simply use methods?

Thanks,
Peter

Peter B. wrote:

Hi,
Can someone tell me how to implement a “go to” kind of statement in
RUBY–GOTO, like in DOS or Windows scripts? If I do an “if” statement
for certain files in a directory, I want to “go to” other parts of the
program to execute certain stuff, kind of like a subroutine. In fact,
does RUBY have subroutines, or, does one simply use methods?

Thanks,
Peter

Hi Peter, “goto” is an ancient philosophical paradigm.
These type of subroutines were replaced with functions (defined by ‘def’
in ruby), it looks like this:

def print_hello(name)
puts('Hello, '+name)
end

print_hello(“Peter”)
print_hello(“Dor”)
print_hello(“Everyone”)

the output will be:

Hello, Peter
Hello, Dor
Hello, Everyone