When I call a solidity function to get a struct element, is it a best practice to use require
and check if the element exists or should I just return the empty values?
Without require:
function getStruct(uint256 _id) returns (address, bool) {
return (structs[_id].addr, structs[_id].boolean);
}
With require:
function getStruct(uint256 _id) returns (address, bool) {
require(structElementExists(_id));
return (structs[_id].addr, structs[_id].boolean);
}
Should view functions fail or should they just return empty results?