[Ethereum] Different number of arguments in return statement

contract-developmentsolidity

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?

Best Answer

You need to do this instead:

return (name, age);

Explanation in the docs here.

Related Topic