5

One issue I've come across frequently lately is in functions which have several return types, for example:

function show() onlyOwner returns(string _name, uint _age) { return name; return age; } Clearly there are two return parameters defined in the function and return is used twice. Yet I'm getting an error:

Different number of arguments in return statement than in return declaration.

This has also happened in more complex return declarations with up to 10 separate statements, but both matched. What is the problem?

4

You need to do this instead:

return (name, age);

Explanation in the docs here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.