Does nim support this? Here is an example in python. (Python dictionaries are hash tables)
array = []
dict = {}
dict['key'] = array
dict['key'].append("Test")
dict['key'].append("Test 2")
print dict['key']
Result: ['Test', 'Test 2']
import tables
var dict = initTable[string, seq[string]]()
dict["key"] = @[]
dict.mget("key").add("Test")
dict.mget("key").add("Test 2")
echo dict["key"]
I think we should replace the mget("key") with ["key"], but this causes ambiguity in the compiler so far because we can't do overloading based on return type.
Edit: Also, while we're at emulating Python's hash tables, this syntax works in Nim as well:
import tables
# These are both the same in Nim, an array of tuples:
let list1 = {"key": 12, "key2": 13}
let list2 = [("key", 12), ("key2", 13)]
# A dictionary from them:
var dict1 = list1.toTable
var dict2 = list2.toTable
# Or directly:
var dict3 = toTable({"key": 12, "key2": 13})