Forum: Ruby Gotcha for Newbies

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D8376641b56fed67d99599d5e7bf9631?d=identicon&s=25 Neowulf (Guest)
on 2006-02-03 02:56
(Received via mailing list)
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...
D8376641b56fed67d99599d5e7bf9631?d=identicon&s=25 Neowulf (Guest)
on 2006-02-03 03:05
(Received via mailing list)
Opps.. correction...

require 'find'

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

~Neowulf
This topic is locked and can not be replied to.