I'm trying to use a mapping inside a struct:
struct PoolStruct {
uint currentUserID;
uint activeUserID;
uint price;
uint minimalReferrals;
mapping(uint => address) poolUserList;
}
the code compiles, so i guess it's somehow permitted. The problem starts when i try to assign to that property:
PoolStruct memory pool;
pool = PoolStruct({
currentUserID: 1,
activeUserID: 1,
price: POOL_PRICES[i],
minimalReferrals: POOL_MINIMAL_REFERRALS[i]
});
pool.poolUserList[1] = msg.sender;
get an error on the last line...
TypeError: Member "poolUserList" is not available in struct Definitions.PoolStruct memory outside of storage.
pool.poolUserList[currUserID] = msg.sender;
^---------------^
Is there any way to make this work?
currUserID
?mapping
only in storage (i.e., non-local) variables. So the same goes for astruct
which holds amapping
.PoolStruct
structure, and redefine it asmapping(uint => PoolStruct) poolUserList
.