Created
December 27, 2023 16:58
-
-
Save clesaege/2bd6722cd3c82ebaf74dd6d0d916b95c to your computer and use it in GitHub Desktop.
Push VS Assign
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity >=0.7; | |
contract Test { | |
struct S {uint a; uint b; uint c;} | |
S[] ss; | |
function f() external { | |
ss.push(S({a:5,b:0,c:2})); | |
} | |
function g() external { | |
S storage s = ss.push(); | |
s.a=5; | |
s.b=0; | |
s.c=2; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment