[Gambas-user] Concatenate collection
adamnt42 at gmail.com
Wed Sep 6 12:05:14 CEST 2023
On 6/9/23 7:07 pm, Marco Ancillotti wrote:
> 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,
Good question! But no, not inbuilt.
However, you could override the Collection class and add say a
Merge(fromCollection as Collection) method, but you'd need to be careful
of how you want to handle collisions.
so then you could for example
to get "a" now containing the four.
Or, you might look at the Collection.Copy source to see if there's
something in there that could spark an idea.
More information about the User