From: Matthew Smillie Date: 2006-07-01T22:46:05+09:00 Subject: Re: Help please On Jul 1, 2006, at 13:24, Dark Ambient wrote: > Recently I asked here about where "end" goes, in relation to code > blocks. I was given some good answers which helped but now either I'm > having a same / similar problem or this is perhaps something > completely different. > pic_names.each do |name| > fcheck = FileTest.exist?(name) > if fcheck == true > puts 'Do you wish to move ' + name + 'file?' > puts 'Please answer "yes" or "no" ' > else puts 'file does not exist' > > end > end It looks a bit to me like the formatting didn't come through entirely intact, but this bit still gives me a hunch at where you're going wrong, and it's still a question of where the 'end' goes for a statement. 'if' statements behave a little differently than loops: the 'else' and 'elsif' (if they're used) don't require their own 'end's, they're considered part of the if statement, and are generally indented to the same level as the initial 'if'. In other words: the 'if' is the beginning of the statement, so that's what matches the 'end'. Here's the usual formatting for the 'if' statement: if elsif else end You can have as many elsif statements as you like (including zero), and zero or one else statements, and the whole construct is finished off with an 'end' If we reformat the snippet of code above, matching the 'end's with what they actually match, it ends up looking like this: pic_names.each do |name| fcheck = FileTest.exist?(name) if fcheck == true puts 'Do you wish to move ' + name + 'file?' puts 'Please answer "yes" or "no" ' else puts 'file does not exist' end end From that I think you can see what part of the problem is. You've got what looks like a similar construction in the while loop as well. I'm not sure that's the only problem in the code, but fixing up your 'end's will certainly get you on your way. matthew smillie. PS: Is your editor using tabs or spaces for indentation? I tried to send myself code over gmail and it came through just fine unless I had a mix of spaces and tabs as indentation, which turned it into muck. If this is the case, there may be an option to indent using spaces. Otherwise, you could probably enter the code manually using spaces to preserve indentation.