4
library Lib{
    struct Data {
        mapping (uint => uint) a;
    }

    function inc(Data self) internal{
        self.a[0] =+1;
    }
}
contract Example{

    address recipient = 0x0000cafebabe;

    Lib.Data data;

    function send(){
        Lib.inc(data);
    }
}

Leads to error

7:9: Error: Member "a" is not available in struct Data memory outside of storage.
        self.a[0] =+1;
        ^----^

1 Answer 1

5

Have your code changed as below

function inc(Data storage self) internal{
        self.a[0]=+1;
    }

Note the storage part of it. Please understand the concepts of Internal Types for variables and In memory types

1
  • 1
    wow didn't know, need to check this Monday, must go to the F1 race with my father this tomorrow Jul 2, 2016 at 19:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.