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

**URL:** <https://www.ruby-forum.com/t/how-to-go-to-in-a-ruby-script/60934>\
**Category:** Ruby\
**Created:** [May 18, 2006, 6:00pm UTC](https://www.ruby-forum.com/t/how-to-go-to-in-a-ruby-script/60934 "2006-05-18T18:00:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [May 18, 2006, 6:00pm UTC](https://www.ruby-forum.com/t/how-to-go-to-in-a-ruby-script/60934/1 "2006-05-18T18:00:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bodikp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e79b87/32.png) [@bodikp](https://www.ruby-forum.com/u/bodikp)\
**Post date:** [May 18, 2006, 6:06pm UTC](https://www.ruby-forum.com/t/how-to-go-to-in-a-ruby-script/60934/2 "2006-05-18T18:06:46Z")

</div>

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
