Skip to content

Populating struct objects with new data and syntax #284

Answered by ndkk
gmluqa asked this question in Q&A
Discussion options

You must be logged in to vote

I did it on the Remix as below, it's no problem. You may show all your code .

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;

contract MyPeople {
    
    struct People {
            uint256 favNum;
            string name;
        }

    People[] public people;

    function addPerson (string memory _name, uint256 _favoriteNumber) public {
            people.push(People(_favoriteNumber,_name ));
            people.push(People(10 , "Tom"));
    }


}

Replies: 2 comments 3 replies

Comment options

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

@gmluqa
Comment options

@ndkk
Comment options

Answer selected by gmluqa
Comment options

You must be logged in to vote
0 replies
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