mirror of https://github.com/status-im/nimplay.git
Add not about mappings.
This commit is contained in:
parent
97d7b70c0c
commit
6f0fbcb4cc
|
@ -73,3 +73,19 @@ contract("Main"):
|
||||||
proc nameGiven(name: bytes32, address {.indexed.}: uint128) {.event.}
|
proc nameGiven(name: bytes32, address {.indexed.}: uint128) {.event.}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Mappings
|
||||||
|
|
||||||
|
Nimplay uses `StorageTable` type to indicated a mapping.
|
||||||
|
|
||||||
|
```nim
|
||||||
|
contract("Registry"):
|
||||||
|
|
||||||
|
names: StorageTable[bytes32, bytes32]
|
||||||
|
|
||||||
|
proc set_name*(k: bytes32, v: bytes32) {.self.} =
|
||||||
|
self.names[k] = v
|
||||||
|
|
||||||
|
proc get_name*(k: bytes32): bytes32 {.self.} =
|
||||||
|
self.names[k]
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue