Re: This is a little weird
On 2012-06-30, at 3:58 PM, Bob Hutchison wrote:
> Hi,
>
> There's some code simple code here (http://play.golang.org/p/xvaJAtVamM) that compiles and runs. If
you remove the comma on line 21 you get a compiler error and what I find an incomprehensible error message:
>
> prog.go:21: syntax error: unexpected semicolon or newline, expecting }
> prog.go:23: non-declaration statement outside function body
> prog.go:24: non-declaration statement outside function body
> prog.go:25: non-declaration statement outside function body
> prog.go:26: syntax error: unexpected }
>
> Really? Is that what's meant to happen? Surely not.
>
> Honestly, I'd have thought the extraneous comma would have been the problem not the solution.
If you have lines 19 through 22 on a single line the trailing comma isn't necessary (works with it and without it)
>
> Cheers,
> Bob