Skip to content

The Hash Mappening

stratact requested to merge stratact/ion:hash-maps into master

It has been decided between @mmstick and I (and with good input from @ids1024) that hash maps are to be created and parsed from using type annotations like hmap[], as in the following:

let hash_map:hmap[] = [key1=value1 key2=value2]

Hash map access is also done as the following:

# echo hash_map[key1]
value1
# let hash_map[key1] = value3
# echo hash_map[key1]
value3

This simplifies the proposed syntax as mentioned in #246 (closed) and doesn't require adding a new keyword for the same effect as what I am doing.

This is work-in-progress, as I plan to support hmap[int], hmap[float], hmap[int[]], etc type annotations. Using hmap[] defaults to hmap[any] or hmap[str].

The keys in the hash maps are always string types, but the value types are identified by the type specified between the [ and ].

Closes #246 (closed)

Edited by Michael Aaron Murphy

Merge request reports