# Exit from def?

**URL:** <https://www.ruby-forum.com/t/exit-from-def/109196>\
**Category:** Ruby\
**Created:** [July 12, 2007, 10:47am UTC](https://www.ruby-forum.com/t/exit-from-def/109196 "2007-07-12T10:47:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [July 12, 2007, 10:47am UTC](https://www.ruby-forum.com/t/exit-from-def/109196/1 "2007-07-12T10:47:07Z")

</div>

def bla

```
  for i in 1 .. 5
        puts i
        for j in 1 .. 5
                puts j
                if j==4
                    then
                        here i want to exit the "bla" def if j==4
                        somenthing like break, but break just

```

interrupt  
the ‘j’ for not the entire procedure; how  
can i do  
that?  
end

```
   end

```

end

tnx

---

<div class="post-metadata">

**Author:** ![mihai](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/35a633/32.png) [@mihai](https://www.ruby-forum.com/u/mihai)\
**Post date:** [July 12, 2007, 10:52am UTC](https://www.ruby-forum.com/t/exit-from-def/109196/2 "2007-07-12T10:52:36Z")

</div>

Bulhac M. wrote:

> def bla
> 
> ```
> for i in 1 .. 5
> puts i
> for j in 1 .. 5
> puts j
> if j==4
> then
> here i want to exit the "bla" def if j==4
> somenthing like break, but break just
> 
> ```
> 
> interrupt  
> the ‘j’ for not the entire procedure; how  
> can i do  
> that?  
> end
> 
> ```
> end
> 
> ```
> 
> end
> 
> tnx

…

for j in 1…5  
puts j  
return if j==4  
end

…

best,  
Dan
