From: Justin Collins Date: 2010-08-03T12:15:45+09:00 Subject: Re: File.new ("write.txt", "w+") results in error On 08/02/2010 07:45 AM, VMDD TECH wrote: > Hello everyone, > > I am new to Ruby. > > If there are spaces between new and (, then ruby 1.9.1p376 considers > it a syntactical error. For example: > > 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? > > By the way, if I write as > File.new "write.txt", "w+" > File.new("write2.txt", "w+") > > then there are no problem. > > Thanks, > > Binh > > It's not a bug. A comma-separated list inside of parentheses is just meaningless in Ruby, which is why you get a syntax error. Parentheses being "optional" for method calls is a feature, however. -Justin