From: Dark Ambient Date: 2006-06-29T02:15:58+09:00 Subject: Re: Beginners question: branching and ends Helps a great deal! TY. I do use indentation and the odd thing is when I cut/paste into the email , the indentation remains intact. I'm not sure what gmail is doing (if anything) once it gets sent. Stuart On 6/28/06, Louis J Scoras wrote: > Stuart; > > I've taken the liberty of reformating your code here. It is really > important you you indent things correctly so that you can see the > structure of the code clearly. You'll see that I've added lines to in > the columns showing each construct and it's matching end tag: > > somearray.each do |x| > | anotherarray.each do |y| > | | if x == y > | | | # ......do something....... > | | else > | | | # .....do something.......... > | | end > | end > end > > See? As you suspected, the first end is paired up with the if/else > construct. As indented above; however, you can plainly see how the > end keywords match up with their controlling constructs. It turns out > that you had the meaning of the last two ends switched in your > comments. > > Everything needs to be properly nested. That is, you need to end the > first do block before you can end the enclosed one. > > I hope that helps a little. > > > -- > Lou. > >