Skip to content

Instantly share code, notes, and snippets.



Last active Jan 18, 2018
What would you like to do?
Import Obj
pragma solidity ^0.4.0;
// import the contract
import "";
// have fun
contract Foo {
// declare and use new Dictionary structure
using Dictionary for Dictionary.Data;
Dictionary.Data private dic;
function Foo() public view returns (uint) {
dic.set(1, "value");
dic.set(2, "foo");
dic.set(123, "bar");
dic.set(1, "new value");
// get an item
dic.get(2); // => '0x666f6f' (byte hex of 'foo')
// get all keys
dic.keys(); // => [1, 2, 123]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment