Redundancy in C#?

前端 未结 17 1539
猫巷女王i
猫巷女王i 2021-02-13 19:28

Take the following snippet:

List distances = new List();

Was the redundancy intended by the language designers? If so, wh

17条回答
  •  情深已故
    2021-02-13 20:02

    In many of the answers to this question, the authors are thinking like compilers or apologists. An important rule of good programming is Don't repeat yourself!

    Avoiding this unnecessary repetition is an explicit design goal of Go, for example:

    Stuttering (foo.Foo* myFoo = new(foo.Foo)) is reduced by simple type derivation using the := declare-and-initialize construct.

提交回复
热议问题