From: gwtmp01@... Date: 2006-06-21T23:25:07+09:00 Subject: Re: Using parenthesis/barackets in ruby On Jun 21, 2006, at 10:07 AM, Justin Vincent wrote: > To my suprise this worked... > def print_dir ( path ) > Dir.foreach(path) do |file_name| > ( > ( > if ( File.ftype( file_name ) == 'directory' ) > ( > print "[dir] #{file_name}\n" > ) > else > ( > print " #{file_name}\n" > ) > end > ) > ) > end > end > > print_dir ('.') > #--------------------------------------------------- > > Is there any reason why I should not be doing this? Since you asked... The following is much more readable to me than your example. That is why I wouldn't throw in all the extra space and parens. Note, I didn't get rid of *all* the parens that Ruby would allow me to, just some of them. I doubt the extra parsing time introduced by the spacing and parens would be problematic but the extra bugs introduced by having to match all the extra parens would probably kill my productivity. def print_dir(path) Dir.foreach(path) do |file_name| if File.ftype(file_name) == 'directory' print "[dir] #{file_name}\n" else print " #{file_name}\n" end end end print_dir '.' Gary Wright