Consider this code.
function getDoctorsList(uint[] memory _docIds) public view returns (doctor[] memory) {
doctor[] memory _doctors;
for(uint i = 0; i < _docIds.length; i++) {
_doctors[i] = doctors[_docIds[i]];
}
return _doctors;
}
Here I am using an array of id's of a mapping and store the appropriate struct instance into a dynamic array of struct instances. But I can not execute this function. It is saying that:
call to DogChain.getDoctorsList errored: VM error: invalid opcode. invalid opcode The execution might have thrown. Debug the transaction to get more information.
Previously, I tried pushing each items. But compiler says, it is not possible. can anyone help me with this?