[Gambas-user] Concatenate collection
benoit.minisini at gambas-basic.org
Wed Sep 6 12:45:51 CEST 2023
Le 06/09/2023 à 12:44, Benoît Minisini a écrit :
> Le 06/09/2023 à 11:37, Marco Ancillotti a écrit :
>> Hi all ,
>> is there a way to unite two collection without doing one key at time ?
>> something like:
>> dim a as collection = [ "val1": 1 , "val2": 2 ]
>> dim b as collection = [ "val3": 3 , "val4": 4 ]
>> print a + b --> [ "val1": 1 , "val2": 2 , "val3": 3 , "val4": 4 ]
>> thank's in advance,
> It would be something like that:
> For Each v In b
> a[b.Key] = v
> Three lines of code should not be a big deal.
> But yes, it could be put into the interpreter as an Insert() method.
And no, I don't think it can be done without adding one key at a time.
Because Collections are hash table.
More information about the User