Re: [Vala] Why can't I use Gee.HashMap as a class property?



2013/7/1 Nadav Vinik <nadavvin gmail com>

Hello

I I use HashMap as a property I get error:
c.vala:26.3-26.5: error: missing generic type arguments
        map[1] = node;
        ^^^

how should I use gee.HashMap as a property to share it between classes?

b.vala compile while c.vala not.

thanks for your help
Nadav

_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list


Hi,

valac said "missing generic type arguments", so I simply added them:

public class Main : Object
{
public static HashMap<int, Node?> map;

static int main ()
{
map = new HashMap<int, Node?>((Gee.HashDataFunc)GLib.direct_hash,
 (Gee.EqualDataFunc)GLib.direct_equal);
var b = data();
var node = new Node();
node.c = {'a', 'b'};
node.d = &b;
map[1] = node;

return 0;
}
}

After that I still had to cast the GLib hash and compare functions to
their Gee counterparts, but now it just compiles. I'm not sure if that
means it does what you want it to though..

Jonas


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