Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Is it OK to tag inline method calls on constructors?

constructors inline method Ok
0
Posted

Is it OK to tag inline method calls on constructors?

0

Using a dot separator to call a method on a new instance is a convenience technique that combines two statements in one. There is no practical difference in the method invocation, in both cases a new instance is created and the method is executed, but in practice the code can create unnecessary anonymous instances and confuse the assignment of the return value. For clarity it is better to use two separate statements with obvious assignments, as the series of examples below illustrate.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.