Last active
July 11, 2017 21:39
-
-
Save brynbellomy/9d4ef5606e4d101cd538bfc8d1b63f3d to your computer and use it in GitHub Desktop.
medium-return-struct-public-func-3.sol
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.13; | |
contract Project | |
{ | |
struct Person { | |
string name; | |
uint funds; | |
} | |
// this is the mapping for which we want the | |
// compiler to automatically generate a getter. | |
mapping(address => Person) public people; | |
// this is what the automatically generated getter | |
// looks like (we don't need to implement this ourselves). | |
function getPerson(address id) | |
public | |
returns (string name, uint funds) | |
{ | |
// copy the data into memory | |
Person memory p = people[id]; | |
// break the struct's members out into a tuple | |
// in the same order that they appear in the struct | |
return (p.name, p.funds); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment