From: Joel VanderWerf Date: 2006-01-28T14:56:21+09:00 Subject: Re: working with file types and directories John Maclean wrote: > This line shows all the files in the current dir. > > This one -should- show all of thier filetypes... > > Dir.foreach(".") {|x| File.ftype x } > => nil > # what gives? > > irb(main):023:0> Dir.foreach(".") {|x| File.ftype(x) } > => nil > > Dir.foreach(".") {|x| File.ftype(#{x})} > # I knew that this wouldn't work, but I tried it anyway > Try this: Dir.foreach(".") {|x| puts File.ftype x } Note that Dir.foreach doesn't return the results of the block. If you want that behavior: require 'enumerator' Dir.enum_for(:foreach, ".").map {|x| File.ftype x } -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407