From: "Kroeger, Simon (ext)" Date: 2006-06-22T00:22:23+09:00 Subject: Re: Using parenthesis/barackets in ruby > -----Original Message----- > From: James Edward Gray II [mailto:james@grayproductions.net] > Sent: Wednesday, June 21, 2006 4:43 PM > To: ruby-talk ML > Subject: Re: Using parenthesis/barackets in ruby > > On Jun 21, 2006, at 9:25 AM, gwtmp01@mac.com wrote: > > > Since you asked... The following is much more readable to > me than your > > example. > > Minor updates to satisfy my own readability scale: > > > def print_dir(path) > > Dir.foreach(path) do |file_name| > > if File.directory? file_name > puts "[dir] #{file_name}" > > > else > > puts " #{file_name}" > > > end > > end > > end > > print_dir '.' > > James Edward Gray II There is no need for control structures anyway: ------------------------------------------------------------- def Dir.listing path prefix = {'directory' => '[dir] ', 'file' => ' '} glob("#{path}/*").map{|file| prefix[File.ftype file] + file} end puts Dir.listing('.') ------------------------------------------------------------- cheers Simon