Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
pragma solidity 0.6.0;

contract Countries{
    
    struct Places {
        string country;
        string state;
    }
    
    Places [] public places;
    
    for(i=0; i<places.length; i++){
        places.push(Places({
            country : places[i],
            state : "No state added"
        }));
    }
}


What I have tried:

I have tried tweaking a code a bit but to know avail
Posted
Updated 2-Feb-21 0:00am
v2
Comments
Richard MacCutchan 2-Feb-21 4:29am    
What parse error, which line?

1 solution

From a brief glance at the Truffle documentation[^], it looks like a contract cannot directly contain executable code. Instead, your code needs to be inside a function.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900