self Is A Valid Type On A Closure

no-email (Damien Seguy), Damien Seguy
Mon, 21 Apr 2025 00:00:00 +0000

``self`` is a valid type inside a class (trait, interface, enum) to reference the current class. ``self`` may also be used with a closure, since the closure use its location of definition. The class name may be exported that way, and instantiated outside the original class.
This applies to ``static`` and ``parent`` too. Try it wit ``static`` for extra fun.
This tips also applies when the closure is made static, although it might be surprising.
This tip applies to arrow functions.
This tip does not applies to functions created in a class (ugh...).