From: Louis J Scoras Date: 2006-06-28T23:44:00+09:00 Subject: Re: Beginners question: branching and ends 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.