Does this compile?

Taking a momentary break from an internal beta…

Does this compile?

var foo = newFooType()


        AnInt = 1,

        AnotherInt = 1,

        MyBar = bar,


If you’re wondering what’s strange here, its the pointless last comma in the type initializer.

Apparently, the compiler doesn’t care. Which is a good thing, if you’re lazy. However, it could be an indication that you’ve forgotten something.

I’m voting its a bug in the compiler.

(Long after the fact update: Its not a bug. Its a common practice to allow the last comma in situations like this (delimited lists).  This has been done for a long time in order to make it easier for automated code generators.)

One Response to Does this compile?

  1. Nope, this is not a bug. This is clearly specified in the language spec and the reason is to help automated generated files and ease of manipulation. This is also true for array initializers. The compiler will ignore the last comma. I think this behavior also exists in C++ compilers.

Comments are closed.