Skip to content

Instantly share code, notes, and snippets.

@uduki
Last active August 29, 2015 14:05
Show Gist options
  • Save uduki/fac28ae24f65c6575661 to your computer and use it in GitHub Desktop.
Save uduki/fac28ae24f65c6575661 to your computer and use it in GitHub Desktop.
Haxeでの構造体の拡張
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