Skip to content

Instantly share code, notes, and snippets.

@francescoagati
Created July 5, 2011 21:04
Show Gist options
  • Save francescoagati/1065933 to your computer and use it in GitHub Desktop.
Save francescoagati/1065933 to your computer and use it in GitHub Desktop.
Why haxe is a better php (2) - autoboxing, enumerations, macros
//support for autoboxing
// https://wiki.php.net/rfc/autoboxing
class Main {
public static function main() {
var hash = new Hash<Dynamic>();
hash.set("key1","value1");
hash.set("key2","value2");
hash.set("key3","value3");
trace(hash.keys());
trace([1,2,3,4,5].join("-").split("-"));
}
}
//support for enumerations
// https://wiki.php.net/rfc/enum
enum Car {
fiat;
ferrari;
ford;
}
class Cars {
static function toLongDescription( c : Car ) : Int {
return switch( c ) {
case fiat: " a fiat car";
case ferrari: "a ferrari car";
case ford: "a ford car";
}
}
}
//support for macros at compile time (like lisp and dylan macros)
// see http://haxe.org/manual/macros for better macros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment