Skip to content

I have a problem in this array of struct #3417

Answered by JamesMckenna
opemy asked this question in Q&A
Discussion options

You must be logged in to vote

@opemy I agree with @pacelliv, we should try to follow posting etiquette.

As for the error you are getting, well the solidity compiler is getting confused.
You are declaring a custom data type of people

struct people {
uint256 favouriteNumber;
string name; // now we have a new type of people,
}

later in your code you are declaring a variable
People[] public people;

The Solidity compiler is asking "what do you mean a variable of people? You have already told me that people is a data type."

so change your custom data type to

struct People {
uint256 favouriteNumber;
string name; // now we have a new type of people,
}

and the compiler will understand that you want to use the custom data t…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@opemy
Comment options

@opemy
Comment options

@JamesMckenna
Comment options

Answer selected by opemy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants