コンテンツ

基本的にここで使っている図版、コードスニペット、および文章は、丸写しするにせよ適当に手を加えて使うにせよ、好きに使ってください。Life-Is-Short License というか、Public Domain です。例外がある場合は都度指示があります。

新着記事

2008-07-06 14:32:01 by admin General

Constという型パラメータは特別な意味を持つ

2008-07-06 14:32:01 by admin General

元ネタはこちら。一言で言うとおもしろそうなんだけどあまり使えないフィーチャー。

class Foo {
    public function new() {}
 
    public function wtf() {
        trace(Type.getClass(this));
    }
}

class Test {
    public static function main() {
        new Foo<"test">().wtf();
    }
}
> implements haxe.rtti.Infos

Const という名前の型パラメータが指定された場所には、どういうわけか定数を与えることができるようになっている。

上の投稿を読むと (書いているのは「Professional Haxe and Neko」の著者の人)、Reflection API でとれるよ〜みたいなことが書いてあるんですが、実際はダメなようです…。残念 (上のサンプルを走らせてみてください)。

Comments

No comment posted on this entry yet.
Post a comment
On this blog comments are pre-moderated. Your comment will only appear after the blog owner validates it.
Please enter 3575 here.