[Gambas-user] Collection Key Error?

Jussi Lahtinen jussi.lahtinen at gmail.com
Mon Jan 28 15:04:36 CET 2019


This is expected behaviour. Just like with arrays:
iArray[123] = 0
iArray[123] = 1

Collection have "exist" method, which might be what you are looking for.
http://gambaswiki.org/wiki/comp/gb/collection


Jussi

On Mon, Jan 28, 2019 at 1:06 PM Denis Crowther <denisc at exemail.com.au>
wrote:

> Hi Guys,
>
> If I add to a collection and the Key already exists the value is simply
> overwritten. No error is raised.
>
> Is this this the expected behaviour or a bug that will be fixed at some
> point?
>
> Regards
> Denis
>
> '----------------------------
> Dim cc As New Collection
>
>    cc.Add("test1", "MainKey")
>    Debug cc["MainKey"]
>
>    cc.Add("test2", "MainKey")
>    Debug cc["MainKey"]
>
> OUTPUT:
> Form1.Button1_Click.68: test1
> Form1.Button1_Click.70: test2
> '----------------------------
> --
> Regards
> Denis
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190128/4afbb255/attachment.html>


More information about the User mailing list