M Mike1970 Well-Known Member Licensed User Longtime User Mar 12, 2020 #1 Hi in B4i how can I copy a map into another? Given the fact the function "GetKeyAt" and "GetValueAt" doens't exists? Thanks!
Hi in B4i how can I copy a map into another? Given the fact the function "GetKeyAt" and "GetValueAt" doens't exists? Thanks!
Andrew (Digitwell) Well-Known Member Licensed User Longtime User Mar 12, 2020 #2 Have you tried B4X: for each ky as object in map1.keys map2.put(ky,map1.get(ky)) next Upvote 0
M Mike1970 Well-Known Member Licensed User Longtime User Mar 12, 2020 #3 Andrew (Digitwell) said: Have you tried B4X: for each ky as object in map1.keys map2.put(ky,map1.get(ky)) next Click to expand... maybe not uh Later i will try it ! Upvote 0
Andrew (Digitwell) said: Have you tried B4X: for each ky as object in map1.keys map2.put(ky,map1.get(ky)) next Click to expand... maybe not uh Later i will try it !
Erel B4X founder Staff member Licensed User Longtime User Mar 12, 2020 #4 The correct answer was posted above. For completeness, here is another option: B4X: Sub CopyObject(o As Object) As Object Dim s As B4XSerializator Return s.ConvertBytesToObject(s.ConvertObjectToBytes(o)) End Sub It will work as long as the keys and values are types supported by B4XSerializator. Upvote 0
The correct answer was posted above. For completeness, here is another option: B4X: Sub CopyObject(o As Object) As Object Dim s As B4XSerializator Return s.ConvertBytesToObject(s.ConvertObjectToBytes(o)) End Sub It will work as long as the keys and values are types supported by B4XSerializator.