Search code examples
axaptadynamics-ax-2012x++

Does X++ have keyword analog to php's self/static?


In most languages there is some way to implicitly refer to the containing class. In PHP it's the self and static keywords. In C# it's entirely unnecessary since you can do this:

class Foo {
  static void A() {
    B();
  }
  static void B() {}
}

But in X++ it appears I have to explicitly use the class name:

Foo::B();

Solution

  • When it comes to static methods, your assumption that in the object name and two colons are needed to call the method is correct, there is no shortcut/keyword that I'm aware of.

    It is however a different case for non-static methods, these can be called using the keyword this (for example for classes and tables) or element (in form code).