Unfortunately, it is possible to make constructor calls recursive. When this happens, you get a class that cannot be instantiated.


As a general rule, no constructor should make a call to another constructor in the same class that requires fewer arguments than the calling constructor received. I.e. the constructor that accepts the most arguments is the one that has the fullest picture of how the class should look. It should perform class initialization.


== Noncompliant Code Example

----
class Foo
{
  int start;

  Foo() : this(0)  { }
  Foo(int v) : this()   { }  // Noncompliant
}
----


== Compliant Solution

----
class Foo
{
  int start;

  Foo() : this(0)  { }
  Foo(int v)
  {
    this.count = v;
  }
}
----


ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]
