pragma solidity ^0.5.12;
contract sample {
mapping(address => uint256[12]) fruits;
function getfruit(address addr) public view returns (uint256[] storage fr) { //line 3
return (fruits[addr]);
}
}
Look at the above code. Here firstly since fruits is public, getfruit() should not be even required. But the auto-generated fruits() only returns index 0 (only the first element) but I want all. Now as far as function is concerned, it gives error when I use 'storage' in line 3. Now if I make it memory , I tried the following code but still throws error saying 'TypeError: Type uint256[12] is not implicitly convertible to uint256[] memory' (which sounds reasonable, but then how do I get the array)?
pragma solidity ^0.5.12;
contract sample {
mapping(address => uint256[12]) fruits;
function getfruit(address addr) public view returns (uint256[] storage fr) { //line 3
uint256[] memory veggies = new uint256[] (12);
veggies = fruits[addr];
return (veggies);
}
}