2019-07-08 14:04:52 +00:00
|
|
|
contract test {
|
|
|
|
struct topStruct {
|
|
|
|
nestedStruct nstr;
|
|
|
|
uint topValue;
|
|
|
|
mapping (uint => uint) topMapping;
|
|
|
|
}
|
|
|
|
uint toDelete;
|
|
|
|
topStruct str;
|
|
|
|
struct nestedStruct {
|
|
|
|
uint nestedValue;
|
|
|
|
mapping (uint => bool) nestedMapping;
|
|
|
|
}
|
2020-06-23 12:14:24 +00:00
|
|
|
constructor() {
|
2019-07-08 14:04:52 +00:00
|
|
|
toDelete = 5;
|
|
|
|
str.topValue = 1;
|
|
|
|
str.topMapping[0] = 1;
|
|
|
|
str.topMapping[1] = 2;
|
|
|
|
|
|
|
|
str.nstr.nestedValue = 2;
|
|
|
|
str.nstr.nestedMapping[0] = true;
|
|
|
|
str.nstr.nestedMapping[1] = false;
|
|
|
|
delete str;
|
|
|
|
delete toDelete;
|
|
|
|
}
|
|
|
|
function getToDelete() public returns (uint res){
|
|
|
|
res = toDelete;
|
|
|
|
}
|
|
|
|
function getTopValue() public returns(uint topValue){
|
|
|
|
topValue = str.topValue;
|
|
|
|
}
|
|
|
|
function getNestedValue() public returns(uint nestedValue){
|
|
|
|
nestedValue = str.nstr.nestedValue;
|
|
|
|
}
|
|
|
|
function getTopMapping(uint index) public returns(uint ret) {
|
|
|
|
ret = str.topMapping[index];
|
|
|
|
}
|
|
|
|
function getNestedMapping(uint index) public returns(bool ret) {
|
|
|
|
return str.nstr.nestedMapping[index];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ----
|
|
|
|
// getToDelete() -> 0
|
|
|
|
// getTopValue() -> 0
|
2021-03-12 23:02:36 +00:00
|
|
|
// getNestedValue() -> 0 #mapping values should be the same#
|
2019-07-08 14:04:52 +00:00
|
|
|
// getTopMapping(uint256): 0 -> 1
|
|
|
|
// getTopMapping(uint256): 1 -> 2
|
|
|
|
// getNestedMapping(uint256): 0 -> true
|
|
|
|
// getNestedMapping(uint256): 1 -> false
|