--0016365eea3cba5fe0048ac80411
Content-Type: text/plain; charset=ISO-8859-1

On Wed, Jul 7, 2010 at 3:23 AM, Iain Barnett <iainspeed / gmail.com> wrote:

> 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"
> }
> {:firstfirst", :secondsecond"}
>
> myhash3  
>  :first "first"
>  , :second "second"
> }
> SyntaxError: (irb):48: syntax error, unexpected ',', expecting '}'
>  , :second "second"
>  ^
>        from /Library/Frameworks/Ruby.framework/Programs/irb:12:in `<main>'
>
>
> 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 `<main>'
>
>
> Iain
>


I don't know the reasoning for that decision [quirk?] but commas at the end
of lines should not hinder commenting out lines



a  
  1 2 ,
  3 4 ,
  5 6 ,
}
a # {5, 1, 3}



a  
  # 1 2 ,
  3 4 ,
  5 6 ,
}
a # {5, 3}



a  
  1 2 ,
  # 3 4 ,
  5 6 ,
}
a # {5, 1}



a  
  1 2 ,
  3 4 ,
  # 5 6 ,
}
a # {1, 3}

--0016365eea3cba5fe0048ac80411--