i fixed this by replacing the line of code where the error happens with
entityStructs.push(newEntity);
return entityStructs.length - 1
it functions the same way but for some reason solidity now accepts it this way and not the other.
i fixed this by replacing the line of code where the error happens with
entityStructs.push(newEntity);
return entityStructs.length - 1
it functions the same way but for some reason solidity now accepts it this way and not the other.
I believe the Public vs External video on Gas Consumption isnât entirely accurate anymore. Prior to Solidity 0.6.9 being released, its true that Gas Consumption for âexternalâ visibility functions could be lower because at the time only âexternalâ functions allowed for the use of calldata in function parameters. However since then âpublicâ functions are also allowed the same privilege. Hence the use of âexternalâ functions with âcalldataâ parameters is no more a huge gas saving tactic as âpublicâ functions afford you the same costs of execution.
I guess now it can be said simply that using âcalldataâ over âmemoryâ saves significant gas costs as long as it fits your use case
Hi,
I donât really understand why in the video, MEMORY => MEMORY is a REFERENCE ???
I tried to verify but for me, it is a COPY.
Can you explain me why is a REFERENCE ?
Here what I tried
pragma solidity 0.7.5;
contract CopyReference{
function memoryReference(string memory name) public pure returns ( bool ) {
string memory before = name;
before="toto";
// name="tata";
if (keccak256(abi.encodePacked(before)) == keccak256(abi.encodePacked(name))){
return true;
}
return false; // It return FALSE, even with name = "tata"
}
}
Carlos Z
I see, I read some article on internet, they said also that assign value from memory to memory is a reference. So why in the code below, itâs not the same value ?
Assigning âtotoâ to before property doesnât change the value of name property.
pragma solidity 0.7.5;
contract CopyReference{
function memoryReference(string memory name) public pure returns ( bool ) {
string memory before = name;
before="toto";
// name="tata";
if (keccak256(abi.encodePacked(before)) == keccak256(abi.encodePacked(name))){
return true;
}
return false; // It return FALSE, even with name = "tata"
}
}