Gotcha for Newbies

N

Neowulf

Hi all,

I just thought I'd drop this one in for any newbie's playing around
with directory listings...

me@somehost> find /somedir > results

File.open("./results").each do |file|
puts file unless File.directory(file)
end

.... What do we think the output should be if given that /somedir
contains both directories and files...

And why does this give you a different result...

require 'find'

Find.find("./results").each do |file|
puts file unless File.directory(file)
end

Yep.. probably *extrememly* obvious to the oldtimers... but drove me
nuts...\n

~Neowulf

Hint: ...chomp...
 
N

Neowulf

Opps.. correction...

require 'find'

Find.find("./somedir").each do |file|
puts file unless File.directory(file)
end

~Neowulf
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,661
Latest member
sxarexu

Latest Threads

Top