Last active
January 18, 2018 21:48
-
-
Save sagivo/2db94edec8b5d68ad6ba75e9ede2cf24 to your computer and use it in GitHub Desktop.
Import Obj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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