Please forgive the beginner question, but how does one make and use a hashtable?
Suppose I want to map a string to an int. This seems to fail:
jaten@i7:~$ nimrod i
config/nimrod.cfg(36, 11) Hint: added path: '/home/jaten/.babel/libs/' [Path]
Hint: used config file '/home/jaten/pkg/nimrod/install/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: stdin [Processing]
>>> import tables
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
>>> var h = TTable[string,int]
>>> h["a"] = 1
stdin(3, 5) Error: type expected
stdin(3, 2) Error: 'AnonType' cannot be assigned to
>>>
### try again, using new
jaten@i7:~$ nimrod i
config/nimrod.cfg(36, 11) Hint: added path: '/home/jaten/.babel/libs/' [Path]
Hint: used config file '/home/jaten/pkg/nimrod/install/nimrod/config/nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: stdin [Processing]
>>> import tables
Hint: tables [Processing]
Hint: hashes [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
>>> var h = new(TTable[int,string])
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
var h = initTable(<put initial size here>)
@leledumbo, Thanks!
>>> var h = initTable[string,int]()
>>> h["a"] = 1
>>> echo(h["a"])
1
>>>
Horray!