i'm glad to follow this forum, it is very helpful. I'm using truffle to develop contracts and i just found that dynamic arrays are not yet suported, for that reason i was using string arrays with a fixed lenght and i found that the element with index 0 is not showing anything and last one says undefined. do you know ay reason of that?, do i have to get elements in a different way??
This is the function in solidity:
pragma solidity ^0.4.21;
pragma experimental ABIEncoderV2;
contract Example {
function getStringArray() public returns (string[]) {
string[] memory resultStr = new string;
resultStr[0] = "355555555";
resultStr[1] = "2";
resultStr[2] = "8888";
return resultStr;
}
}
I also did a test with truffle like this:
in javascript i test getting elements one by one and i got this:
var ExampleCont = artifacts.require("Example");
contract('ExampleCont', async(accounts) => {
before(async () => {
ExampleContract = await ExampleCont.new();
});
it('Upload File', async () => {
let stringArray = await ExampleContract.getStringArray.call();
console.log("list size=" + stringArray.lenght+"0="
+ stringArray[0] + "1="+stringArray[0]+", 2=" + stringArray[1] + "3=" + stringArray[2]);
}
}
list size=3, value 0= , 1=355555555, 2=2, 3=undefined
any idea about what's happening in this case?, how do i have work well with string arrays to get all elements?
pragma solidity
)!pure
norview
). You should post accurate details if you want to get proper help here.view
orpure
???Error: Type function (uint256) returns (string memory) is not implicitly convertible to expected type string memory[] memory.
on the linestring[] memory resultStr = new string;
.