Mark Romano
Jul 7, 2018 · 1 min read

Great article,,, thanks for sharing.

I did a little experimenting of my own. I wrote this contract, deployed it on remix and played with it.

contract Test {
struct Struct {
uint val;
}

Struct public myStruct = Struct(5);


function memInc() public {
Struct memory copy = myStruct;
myStruct.val++;
}

function stoInc() public {
Struct storage copy = myStruct;
myStruct.val++;
}
}

Based on what you wrote, I figured only stoInc would mutate myStruct , but both do. Why is that?

    Mark Romano

    Written by

    Full snack dev. Find me on the twitter https://twitter.com/RotundUrsine

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade