Add step proc for symbols
This commit is contained in:
parent
eeef9860cf
commit
7718227662
|
@ -273,6 +273,14 @@ func step*(pr, idx: Preserve): Option[Preserve] =
|
|||
if i < pr.len:
|
||||
result = some(pr[i])
|
||||
|
||||
func step*[E](pr: Preserve[E]; key: Symbol): Option[Preserve[E]] =
|
||||
## Step into dictionary by a `Symbol` key.
|
||||
if pr.isDictionary:
|
||||
for (k, v) in pr.dict.items:
|
||||
if k.isSymbol and k.symbol == key:
|
||||
result = some(v)
|
||||
break
|
||||
|
||||
proc `[]=`*(pr: var Preserve; key, val: Preserve) =
|
||||
## Insert `val` by `key` in the Preserves dictionary `pr`.
|
||||
for i in 0..pr.dict.high:
|
||||
|
|
Loading…
Reference in New Issue