1

Question 1: What i am trying to make is an array of struct "someStruct" which will be "someStructs". Now i am setting some values in the struct array at index "_prop1" in "createSomeStruct()". Now if i want to set further values of the struct at the same index "_prop1", which i am trying to do in addUsers function. How will i do that?

Question 2: Is it possible to have a mapping inside the struct, if yes how can we do that, if you could direct me to some documentation or example for that.

pragma solidity ^0.4.10;

contract A {

    struct someStruct{
        uint prop1;
        uint prop2;
        address [] users;
    }


    mapping (uint => someStruct) public structList;
    someStruct[] public someStructs;

    function createSomeStruct(uint _prop1, uint _prop2){
        structList[_prop1].prop1 = _prop1;
        structList[_prop1].prop2 = _prop2;
        someStructs.push(structList[_prop1]);
    }

    function addUsers(uint _prop1, address _userAddress){
        structList[_prop1].users.push(_userAddress);
        //....?

    }
}

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.