[Gambas-user] Collections and 0 values.

Martin mbelmonte at belmotek.net
Mon Nov 16 20:34:28 CET 2020

Hi Tobias,

Yes I actually use JSONCollection for that, my question was in a 
philosophical sense, just I want to know why is like this.

Anyway, I will prepare a small sample project for fun.



On 16/11/20 10:10, Tobias Boege wrote:
> On Mon, 16 Nov 2020, Martin wrote:
>> Hi,
>> I'm using collecions to storage spatial data of some CAD entitites like
>> lines, text, etc. one of the tags are the angle, in radians, then when if i
>> want to storage non 0 values no problem, but when the angle is 0 the tag :
>> value is not added.
>> I have seen this behavior before in collections with null values and of
>> course with 0 values, like the one I am trying to use now.
>> The question is why is this defined like this? What sense does it make?
>> Would it be possible to support 0 values by changing something in the
>> configuration?
>> If 0 is a valid value to start counting an array, why is it not valid to
>> define a 0 value?
>> Another related issue is settings, since it has the same behavior, what is
>> the logic of this? the set of names of the variables that have value "" is
>> lost.
>> Thanks.
> In Gambas, Null and the empty string are equivalent. Assigning Null to
> a Collection key is the same as removing it. To emulate languages which
> treat their analogues of "" and Null differently, you have to invent
> your own sentinel Null value like it was done for JSON [1]. If you need
> a Collection which stores Gambas Null values instead of taking this as
> a cue to delete the key, you can use JSONCollection, despite its name.
> Null and the integer zero are not equivalent in Gambas and I doubt that
> assigning coll[key] = 0 will delete key. Can you isolate the code you
> have problems with into a very small test, which clearly shows what
> you put it and what you expect to get out, without a great big project
> and UI attached?
> Best,
> Tobias
> [1] http://gambaswiki.org/wiki/comp/gb.web/json/null

More information about the User mailing list