Skip to content

Instantly share code, notes, and snippets.

@commel
Last active August 29, 2015 14:06
Show Gist options
  • Save commel/416223b451ae589beb5d to your computer and use it in GitHub Desktop.
Save commel/416223b451ae589beb5d to your computer and use it in GitHub Desktop.
Example of Static Extension in Haxe , see also http://haxe.org/manual/lf-static-extension.html
using Main.StringExtender;
class Main {
static function main() {
trace("hallo".makeUp());
}
}
class StringExtender {
static function makeUp(s:String) {
return s.toUpperCase();
}
}
@commel
Copy link
Author

commel commented Sep 3, 2014

compiles to:

(function () { "use strict";
var Main = function() { };
Main.main = function() {
        console.log(StringExtender.makeUp("hallo"));
};
var StringExtender = function() { };
StringExtender.makeUp = function(s) {
        return s.toUpperCase();
};
Main.main();
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment