# Do loops and braces

**URL:** <https://rubytalk.org/t/do-loops-and-braces/29089>\
**Category:** ruby-talk\
**Created:** [19 July 2006 12:10 UTC](https://rubytalk.org/t/do-loops-and-braces/29089 "2006-07-19T12:10:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aidy2](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@aidy2](https://rubytalk.org/u/aidy2)\
**Post date:** [19 July 2006 12:10 UTC](https://rubytalk.org/t/do-loops-and-braces/29089/1 "2006-07-19T12:10:05Z")

</div>

Is there anyway I can envelop this in braces and not have a loop 'end'?

&nbsp;&nbsp;def goto\_territory\_list  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ObjectMap.new.instance\_eval do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sales\_admin\_link.click  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;territories\_link.click  
&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;end  
&nbsp;&nbsp;  
Thanks

Aidy

---

<div class="post-metadata">

**Author:** ![Michael\_Fellinger1](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@Michael\_Fellinger1](https://rubytalk.org/u/Michael_Fellinger1)\
**Post date:** [19 July 2006 12:17 UTC](https://rubytalk.org/t/do-loops-and-braces/29089/2 "2006-07-19T12:17:24Z")

</div>

> Is there anyway I can envelop this in braces and not have a loop 'end'?

just do it 🙂  
though it's common practice to use do ... end for blocks over more than one  
line

> **···**
>
> On Wednesday 19 July 2006 21:10, aidy wrote:
> 
> > &nbsp;&nbsp;def goto\_territory\_list  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ObjectMap.new.instance\_eval do  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sales\_admin\_link.click  
> > &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;territories\_link.click  
> > &nbsp;&nbsp;&nbsp;&nbsp;end  
> > &nbsp;&nbsp;end
> > 
> > Thanks
> > 
> > Aidy

---

<div class="post-metadata">

**Author:** ![Nate\_Smith2](https://avatars.discourse-cdn.com/v4/letter/n/c6cbf5/32.png) [@Nate\_Smith2](https://rubytalk.org/u/Nate_Smith2)\
**Post date:** [19 July 2006 14:12 UTC](https://rubytalk.org/t/do-loops-and-braces/29089/3 "2006-07-19T14:12:10Z")

</div>

I find that slightly annoying as well. When I use brackets, text editors  
like emacs, jEdit, etc, will show me how each bracket matches up to a  
previous bracket, but they will not show the "do" that matches up with an  
"end" when I type it.

If I have many nested if, while, do, etc, statements, the only way to  
overcome this disability is to comment end tokens (and keeping track of  
these comments over a mutli-version distribution can be very time  
consuming, and error-prone.)

Nate

> **···**
>
> On Wed, 19 Jul 2006, Michael Fellinger wrote:
> 
> > On Wednesday 19 July 2006 21:10, aidy wrote:  
> > \> Is there anyway I can envelop this in braces and not have a loop 'end'?
> > 
> > just do it 🙂  
> > though it's common practice to use do ... end for blocks over more than one  
> > line
