Why does the code below contain an error (ParserError: Expected identifier but got '=').
contract Test {
struct Box {
uint size;
}
Box public box;
box.size = 3; //<-- error here
constructor() public {
}
}
It works if I put the box.size = 3; into the constructor!
contract Test {
struct Box {
uint size;
}
Box public box;
constructor() public {
box.size = 3;
}
}