From: Brian Candler Date: 2010-08-04T18:51:50+09:00 Subject: Re: File.new ("write.txt", "w+") results in error Eugen Ciur wrote: > File.new ("write.txt", "w+") > > => > syntax error, unexpected ',', expecting ')' > File.new ("write.txt", "w+") > ^ > ...: syntax error, unexpected ')', expecting $end > > Is this a ruby bug or is it a feature/quirk of ruby? The latter, because in ruby the parentheses surrounding the argument list are optional. Consider the difference here: puts (2-3).abs ## means: puts((2-3).abs) puts(2-3).abs ## means: (puts(2-3)).abs [The latter fails, because puts returns nil, and nil.abs is not defined] So if you include a space, the parentheses are considered part of the first argument. If you don't include a space, the parentheses are wrapping the argument list. In ruby 1.8, puts (2,3) ## accepted with warning puts (2,3).abs ## syntax error In ruby 1.9, they are both treated as a syntax error. -- Posted via http://www.ruby-forum.com/.