Created
July 5, 2011 21:04
-
-
Save francescoagati/1065933 to your computer and use it in GitHub Desktop.
Why haxe is a better php (2) - autoboxing, enumerations, macros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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("-")); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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"; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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