[Vala] Generic type argument



Hi all,

I tried to store a double in a Gee.Map for some algorithms I'm
writing, but the program failed to compile (with valac errors). After
reading a bit in the tutorial[1] and the reference draft[2], I decided
to try the example in the reference manual[3]. However, the program
failed to compile with the same error I had in my algorithms:

"error: `double' is not a supported generic type argument, use `?' to
box value types"

So I changed that line a bit to look like:

var t = new Two < int, double? > ();

With that line, it compiles (with some warnings), but the output is
not correct. It outputs some 'random' value instead of 5.
So what can i do to make the program compile and make it do what it's
supposed to do?

Thanks a lot,
Thomas

[1] http://live.gnome.org/Vala/Tutorial
[2] http://www.vala-project.org/doc/vala-draft/
[3] http://www.vala-project.org/doc/vala-draft/generics.html#genericsexamples



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]