This question already has an answer here:
- Golang: convert slices into map 2 answers
I have an array of strings whose length is always a multiple of two.
I want to create a map out of this array, so that
myarr = ["key1", "val1", "key2", "val2", ...]
becomes a map where
mymap := mapify(myarr)
mymap['key1'] == "val1"
mymap['key2'] == "val2"
In Python I can do this with the following code
mymap = {}
for x, y in zip(*[iter(myarr)]*2):
mymap[x] = y
</div>