In ActionScript 3, constructor code is always interpreted rather than compiled by the JIT at runtime, which is why the body of a constructor should be as lightweight as possible. As soon as a constructor contains branches ("if", "for", "switch", ...) an issue is logged.


== Noncompliant Code Example

----
public class Foo
{
  public function Foo()
  {
    if (condition) {  // Noncompliant
      // ...
    }
  }
} 
----


== Compliant Solution

----
public class Foo
{
  public function Foo()
  {
    init()
  }

  private function init():void 
  {
    if (condition) { 
      // ...
    }
  }
} 
----


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

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