From 432aa79e61c1fbfa2ef962510167068fa9c3172d Mon Sep 17 00:00:00 2001 From: gxcoder <47691898+gxcoder@users.noreply.github.com> Date: Wed, 9 Feb 2022 18:42:52 -0500 Subject: [PATCH] Suggestion for higher solidity version Operation push has changed behavior since since solidity 0.6. It no longer returns the length but a reference to the added element. --- lesson-1/chapter-13/Contract.sol | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lesson-1/chapter-13/Contract.sol b/lesson-1/chapter-13/Contract.sol index 8e834a2..7fed6be 100644 --- a/lesson-1/chapter-13/Contract.sol +++ b/lesson-1/chapter-13/Contract.sol @@ -15,7 +15,8 @@ contract ZombieFactory { Zombie[] public zombies; function _createZombie(string _name, uint _dna) private { - uint id = zombies.push(Zombie(_name, _dna)) - 1; + zombies.push(Zombie(_name, _dna)); + uint id = zombies.length - 1; emit NewZombie(id, _name, _dna); } @@ -29,4 +30,4 @@ contract ZombieFactory { _createZombie(_name, randDna); } -} \ No newline at end of file +}