Last active
August 29, 2015 14:05
-
-
Save uduki/fac28ae24f65c6575661 to your computer and use it in GitHub Desktop.
Haxeでの構造体の拡張
This file contains hidden or 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
package; | |
import cpp.Lib; | |
typedef A = { hoge:Int } | |
typedef B = { piyo:Int } | |
typedef C = { > A, > B, } | |
class Main { | |
public static function main() { | |
var x = { hoge: 1, piyo: 2 }; | |
print1(x); | |
print2(x); | |
} | |
public static function print1( x:C ) { | |
Lib.println(x); | |
} | |
public static function print2( x:{ > A, > B, } ) { | |
Lib.println(x); | |
} | |
} | |
/* | |
> Aなどだけを集めて拡張をする場合、閉じ}の前にカンマが必要! | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment