[Gambas-user] Collections and 0 values.
taboege at gmail.com
Mon Nov 16 10:10:50 CET 2020
On Mon, 16 Nov 2020, Martin wrote:
> 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
> 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
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 . 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?
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
More information about the User