1

I'd like to include an internal method in my contract that allows the creation of a new uint256 in storage named by a parameter. Something like:

function createUint (string memory _name) internal {
    /*
     * creates a new uint256 named _name in storage
     */
}

My guess is that it would require inline assembly, but I can't figure out how

a94
  • 564
  • 1
  • 7
  • 16

1 Answers1

5

How about a mapping?

mapping(string => uint256) myMap;

function setValue(string memory name, uint256 value) internal {
    myMap[name] = value;
}
user94559
  • 59,196
  • 6
  • 103
  • 103