From: James Harrison Date: 2010-08-02T22:21:05+09:00 Subject: Re: Iteration through File.file? misses entries for which File.file?(entry) == true >> >> def getFiles(dir) >> pwdFiles = Array.new >> >> Dir.foreach(dir) do |entry| >> pwdFiles.push(entry) if File.file?(entry) == true >> end >> end >> The symbolic constant for truth is True, not true. In either case, because File.file? returns either True or False, you can drop the comparison: >> def getFiles(dir) >> pwdFiles = Array.new >> >> Dir.foreach(dir) do |entry| >> pwdFiles.push(entry) if File.file?(entry) >> end >> end If this is truly a method in an object, though, bear in mind scoping issues. pwdFiles is only available inside this method definition. When you declare it in your intialize statement, prepend with a scope-changing symbol. The most common in this case is @ def initialize #will contain all file entries in the directory @pwdFiles = [] end def get_files(dir) @pwdFiles = Array.new Dir.foreach(dir) do |entry| @pwdFiles.push(entry) if File.file?(entry) == true end end And pay attention to the advice about camelCase versus snake_case for method names: because Ruby's duck typed, it's helped me out sometimes to be able to glance at my code and tell what is a variable and what isn't very quickly. Best James