From: Iain Barnett Date: 2010-07-07T17:23:36+09:00 Subject: Hashes don't allow preceding commas by design? This is the output from irb that shows ruby 1.9.1 doesn't like hash entries to be preceded by a comma, only ended by one: myhash3 = { :first => "first", :second => "second" } {:first=>"first", :second=>"second"} myhash3 = { :first => "first" , :second => "second" } SyntaxError: (irb):48: syntax error, unexpected ',', expecting '}' , :second => "second" ^ from /Library/Frameworks/Ruby.framework/Programs/irb:12:in `
' I prefer to put my comma's at the front of a line as it makes a line easier and quicker to comment out (1 vs 2 lines and a lot less fiddly). Is this only-commas-at-the-end by design or did I miss something? I've tested this with a script and with irb. Quick addendum, thought I'd test this for arrays too, and it's the same. myarr = [ 1, 2, 3] [1, 2, 3] myarr2 = [ 1, 2, 3 ] [1, 2, 3] myarr3 = [ 1 ,2 ,3 ] SyntaxError: (irb):58: syntax error, unexpected ',', expecting ']' from /Library/Frameworks/Ruby.framework/Programs/irb:12:in `
' Iain