-
receiving a declaration error for this line of code, undeclared identifier. full thing below pragma solidity ^0.6.0;
contract SimpleStorage {
//this will get initialized to 0!
uint256 favoriteNumber;
struct People {
uint256 favoriteNumber;
string name;
}
People public person = People({favoriteNumber: 2, name: Patrick});
function store(uint256 _favoriteNumber) public {
favoriteNumber = _favoriteNumber;
}
// view, pure
function retrieve() public view returns(uint256) {
return favoriteNumber;
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
cromewar
Dec 8, 2021
Replies: 1 comment 2 replies
-
Hello @TwoDogsOneBigOneSmall Best regards, Cromewar. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
cromewar
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @TwoDogsOneBigOneSmall
Solidity does not support default parameters, so setting up
{favoriteNumber: 2, name: Patrick}
is not valid. You should set those values at execution, not at declaration. However, there is a workaround if you want to set default values. you can refer to this thread.Best regards, Cromewar.