syntax error, unexpected kEND

633 views Asked by At
def read_dbf(paste)
    #Lendo a pasta
    Dir.foreach(paste) { |name| 
        if(File.directory?(name))

            pasteSub = paste+"/"+name
            Dir.foreach(pasteSub) { |subname| 
                puts "Pasta: #{pasteSub}"
                puts subname } 
            end
        end
        }
    end
end

Error: syntax error, unexpected kEND

I tried to create a block within a block and I think given problem. I am listing the contents of the folder and case folder for the content they access and read the contents of the folder as well.

Problem happened when I put the "if"

1

There are 1 answers

1
Lukas Baliak On BEST ANSWER

Yes, you add if and miss some end there. Try to use some editor for show you unexpected end.

def read_dbf(paste)
  #Lendo a pasta
  Dir.foreach(paste) {|name|

    if File.directory?(name)
      pasteSub = paste+"/"+name
      Dir.foreach(pasteSub) {|subname|
        puts "Pasta: #{pasteSub}"
        puts subname
      }
    end

  }
end