Import Obj
pragma solidity ^0.4.0; | |
// import the contract | |
import "github.com/sagivo/solidity-utils/contracts/lib/Dictionary.sol"; | |
// 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