コンテンツ

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

新着記事

2008-07-06 05:28:19 by admin General

enum型の構築子による値同士の比較はできない

2008-07-06 05:28:19 by admin General

どうも、ご無沙汰です。

さて、これ、意外にハマりどころだと思うんです。つまり、

enum Foo {
  foo(a: Int);
}

...

trace(foo(1) == foo(1)); // results in "false"

っていう話なのですが。

Nicolas は「まーそのうちやろうかな」的なノリみたいですね。

> Hello list,
> 
>   I have one more language suggestion: I think it might be useful to
>   be able to use == and != statement to compare enums with parameters
>   as well, for instance:

== already works for enums with no parameter. But it's true that 
comparison is currently not recursive. I'll think about a way to improve 
that but don't hold your breath :)

Nicolas
haXe 2.0 では改善されるのかなあ。されないだろうなあ。

追記: Type.enumEq() というユーティリティ関数を使うと一応 enum 同士の比較はできます。

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 6700 here.