Search code examples
ruby-on-railsrubyjruby

syntax error, unexpected kEND


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"


Solution

  • 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