From: John Maclean Date: 2006-01-29T20:37:48+09:00 Subject: Re: working with file types and directories Thanks for that reply... I've gone through the great guide here http://pine.fm/LearnToProgram/ in order to get me up to speed with itteration. Essentialy what I'd like to do is to check some data within a directory. Those files are essential to the rest of the program as this is where the data "lives". The following line check all files within the dir and prints a message only if all of the files are writable. It's rather useful to see this message once as there are loads of files within that dir. puts "all files have been checked and are writable" if Dir.new(".").all? {|x| FileTest.writable?(x) } # this message is only printed once. Your one-liner prints that message for every time it detects a writable file. On Sun, 29 Jan 2006 13:41:22 +0900 YANAGAWA Kazuhisa wrote: > In Message-Id: <20060129143153.13a84c8e@localhost.localdomain> > John Maclean writes: > > > puts "files have been checked" if Dir.foreach(".") {|x| puts > > FileTest.writable?(x) } == "true" > > Dir.foreach returns nil, nil != "true" so the condition can not be > met. I think you want to do the following, right? > > Dir.foreach(".") {|x| puts "file have been checked" if > FileTest.writable?(x)} > > where print out the message for each x which is a name of writable > file in the current directory. > > -- John Maclean MSc (DIC) 07739 171 531