I have a function xyz :

uint256 a;
uint256 b;
function xyz() internal view return(uint256,uint256){
return (a,b);

Now, I wish to use the first return value in another function (for eg):

uint256 c;
function abc() public {
c += xyz().0; // c += a is desired

What should be the correct syntax.

1 Answer 1


In Solidity you can ignore one or all of the returned values by just not assigning them to the variables:

(uint a, ) = xyz();

The code above would only get the first returned value and ignore the second one.

(, uint b) = xyz();

This code would only get the second returned value.

uint256 c;
function abc() public {
 (uint a, ) = xyz();
 c += a;

This is how you would do it with your example.

  • Thanks, that seems like a very simple solution indeed. Jan 16, 2022 at 12:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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