Bob Hazard wrote:
> I had never heard of EnumClass or EnumValue until I saw your code but
> after a quick play around with it the following seems to actually
> work:
>
>
> enum Something
> {
> TEST1,
> TEST2,
> TEST3;
>
> public string toString ()
> {
> return ((EnumClass)typeof (Something).class_ref ()).get_value
> (this).value_name;
> }
> }
>
> void main()
> {
> Something e = Something.TEST3;
>
> print (e.toString () + "\n");
> }
>
>
> b...@tbird:~/Projects/obj$ valac enumtest.vala
> b...@tbird:~/Projects/obj$ ./enumtest
> SOMETHING_TEST3
For this special case you do not need any extra code:
enum Something {
TEST1,
TEST2,
TEST3
}
void main () {
Something e = Something.TEST3;
print ("%s\n", e.to_string ());
// Or even shorter:
print (@"$e\n");
}
Best regards,
Frederik
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list