pragma solidity ^0.4.0;
contract TestcaseResetObject {
MyObject ob;
struct MyObject {
mapping(uint8 => uint) map;
}
event Output(uint number);
function makeNew() {
ob = MyObject();
ob.map[0] += 1;
Output(ob.map[0]);
}
}
When I run makeNew
repeatedly in browser-solidity, I'm expecting to get every time the event Output(1)
. Instead, I get Output(1)
, Output(2)
, Output(3)
, etc.
It seems when I create a new MyObject
, the map isn't actually created again.
Another question relates that freshly initialized struct should have a "zero" value in all its members. This seems true for uint
's etc. but since mapping seems to "remember" its old values this seems not to be the case.
Any ideas?