added getOrDefault; bootstrapping works again
This commit is contained in:
parent
d8b0edc323
commit
2fda95a4d6
9 changed files with 52 additions and 40 deletions
|
|
@ -122,6 +122,11 @@ proc mget*(t: StringTableRef, key: string): var string {.deprecated.} =
|
|||
## ``KeyError`` exception is raised. Use ```[]``` instead.
|
||||
get(t, key)
|
||||
|
||||
proc getOrDefault*(t: StringTableRef; key: string): string =
|
||||
var index = rawGet(t, key)
|
||||
if index >= 0: result = t.data[index].val
|
||||
else: result = ""
|
||||
|
||||
proc hasKey*(t: StringTableRef, key: string): bool {.rtl, extern: "nst$1".} =
|
||||
## returns true iff `key` is in the table `t`.
|
||||
result = rawGet(t, key) >= 0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue