[Gambas-user] Concatenate collection

Benoît Minisini 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,
>> marco.
>>
> 
> It would be something like that:
> 
> For Each v In b
>    a[b.Key] = v
> Next
> 
> Three lines of code should not be a big deal.
> 
> But yes, it could be put into the interpreter as an Insert() method.
> 
> Regards,
> 

And no, I don't think it can be done without adding one key at a time. 
Because Collections are hash table.

Regards,

-- 
Benoît Minisini.



More information about the User mailing list