Skip to main content
Post Made Community Wiki by Kazark
deleted 62 characters in body
Source Link
Kavet Kerek
  • 1.1k
  • 8
  • 13

I like a lot of answers and would just like to add this:
It makes the reading of code easier
Not that this situation would happen often, but consider you wanted a method in the name of a verb that shared the same name as a noun. C# and other language naturally have the word object reserved. But if it were not then would Foo = object() be the result of the object method call or would it be instantiating a new object. Hopefully said language without the new keyword has protections against this situation, but by have the requirement of the new keyword before the calling of a constructor you allow the existence of a method with the same name as an object.

edit
just realized my answer is similar to Stephen C.

I like a lot of answers and would just like to add this:
It makes the reading of code easier
Not that this situation would happen often, but consider you wanted a method in the name of a verb that shared the same name as a noun. C# and other language naturally have the word object reserved. But if it were not then would Foo = object() be the result of the object method call or would it be instantiating a new object. Hopefully said language without the new keyword has protections against this situation, but by have the requirement of the new keyword before the calling of a constructor you allow the existence of a method with the same name as an object.

edit
just realized my answer is similar to Stephen C.

I like a lot of answers and would just like to add this:
It makes the reading of code easier
Not that this situation would happen often, but consider you wanted a method in the name of a verb that shared the same name as a noun. C# and other language naturally have the word object reserved. But if it were not then would Foo = object() be the result of the object method call or would it be instantiating a new object. Hopefully said language without the new keyword has protections against this situation, but by have the requirement of the new keyword before the calling of a constructor you allow the existence of a method with the same name as an object.

Source Link
Kavet Kerek
  • 1.1k
  • 8
  • 13

I like a lot of answers and would just like to add this:
It makes the reading of code easier
Not that this situation would happen often, but consider you wanted a method in the name of a verb that shared the same name as a noun. C# and other language naturally have the word object reserved. But if it were not then would Foo = object() be the result of the object method call or would it be instantiating a new object. Hopefully said language without the new keyword has protections against this situation, but by have the requirement of the new keyword before the calling of a constructor you allow the existence of a method with the same name as an object.

edit
just realized my answer is similar to Stephen C.