Skip to content

Instantly share code, notes, and snippets.

@alexroan
Last active March 24, 2020 15:21
Show Gist options
  • Save alexroan/61a4f6962d891d27b71f5f8bf9ca83cb to your computer and use it in GitHub Desktop.
Save alexroan/61a4f6962d891d27b71f5f8bf9ca83cb to your computer and use it in GitHub Desktop.
examples/solidity-structs
pragma solidity >=0.5.0;
contract Structs {
// Define the Person struct
struct Person {
string name;
uint8 age;
}
// Create a new person struct,
// Access the age of the struct
function personAge() external pure returns(uint8) {
Person memory person = Person("Alex", 27);
// Will return 27
return person.age;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment