Hi all, I use a HashTable (GLib) to count how ofter some strings occur within a file. If I define the HashTable dupl_map as "new HashTable<string, uint?>(str_hash, str_equal)" and a "uint? current_count", I can do a test "if ((current_count = dupl_map.lookup(str)) != null)" and then either increment and re-insert the current_count or else create a new entry. However, since I never store null as value, I would prefer to declare a HashTable<string, uint> -- without the theoretically unnecessary question mark. If I do so, however, the test "((current_count = dupl_map.lookup(str)) != null)" never becomes true (even though current_count is still an uint? ). Instead of the null value that the HashTable should return for unknown keys, it returns a numeric 0. That contradicts the documentation and makes the usage of HashTables with non-nullable values impossible. I suppose the problem is caused by the fact that the declaration of the method in glib-2.0.vapi is wrong. Instead of public unowned V lookup (K key); it should be public unowned V? lookup (K key); to allow returning null even if V itself is non-nullable. Is this a known issue or should I report a bug? I use Vala 0.13.1. Thanks and best regards Christian -- |------- Dr. Christian Siefkes ------- christian siefkes net ------- | Homepage: http://www.siefkes.net/ | Blog: http://www.keimform.de/ | Peer Production Everywhere: http://peerconomy.org/wiki/ |---------------------------------- OpenPGP Key ID: 0x346452D8 -- Culture is made everywhere by everyone... -- Open letter by commoners to Brazilian President Rousseff, 2011
Attachment:
signature.asc
Description: OpenPGP digital signature