[Vala] foreach / Gee.Tree/HashMap
- From: Dennis Möhlmann <in dev nyda info>
- To: Vala-list <vala-list gnome org>
- Subject: [Vala] foreach / Gee.Tree/HashMap
- Date: Tue, 21 Aug 2012 05:34:29 +0200
Hello,
I was running into an issue with Gee Maps and was wondering if this is
intended behaviour. Here's a minimal sample:
var map = new HashMap<int, string>();
map[1] = "first";
map[2] = "second";
foreach (var value in map) {
stdout.printf((value ?? "null") + "\n");
}
stdout.printf("--\n");
foreach (var entry in map.entries) {
stdout.printf((entry.value ?? "null") + "\n");
}
The resulting output is:
null
first
--
first
second
The first loop seems to start at the non-existing key 0. Adding map[0] =
"test" seems to confirm that:
test
first
second
--
test
first
second
"Gaps" in the map-keys produce similar issues. Looks like a bug to me,
but I thought I'd ask here first.
Regards,
Dennis
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]