it's very tricky,
when in the truffle , I call f(),it can't push an item into addressArray.(console.log(addressArray[0]) always unidifined))
but when I use Remix, it worked.
pragma solidity ^0.6.6;
contract Test{
address[] public addressArray;
function f() public {
addressArray.push(msg.sender);
}
}
f()
? How are you accessingaddressArray
? It should be possible. To accessaddressArray
from the truffle's console you should do something likeconsole.log(await testContract.addressArray(0))
, since it is a getter function.console.log(await testContract.addressArray.length)
it's undifined