HaxeFoundation / haxe.org-comments

Repository to collect comments of our haxe.org websites
2 stars 2 forks source link

[haxe.org/manual] Static Extension (Language Features) #114

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Static Extension (Language Features) - Haxe - The Cross-platform Toolkit

Haxe is an open source toolkit based on a modern, high level, strictly typed programming language.

https://haxe.org/manual/lf-static-extension.html

daverave1212 commented 2 years ago

What happens if the variable I'm using the extension on is null?

final x: Dynamic = null;
x.anExtensionMethod();
Gama11 commented 2 years ago

That depends on how the extension method's implementation handles null.

ea7ababe commented 5 months ago

Why using Main.IntExtender instead of using IntExtender? IntExtender itself is not inside of the Main class.

kLabz commented 5 months ago

using x.Y.Z means using package x, module Y, type Z, and not class Y. IntExtender is inside module Main.

IntExtender itself is not inside of the Main class.

This wouldn't make any sense anyway since Haxe doesn't allow defining types inside classes.

ea7ababe commented 5 months ago

using x.Y.Z means using package x, module Y, type Z, and not class Y. IntExtender is inside module Main.

Oh, that makes sense. And, I guess, just using IntExtender doesn't compile, even if called from the same module...

This wouldn't make any sense anyway since Haxe doesn't allow defining types inside classes.

Interesting, the manual doesn't seem to mention that anywhere, so I haven't even checked. But that's good - simpler language = less headache.

Thanks for clarifying!