Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the meaning of comma sequence like ,,,,, in Solidity?

I recently came across the following Solidity function:

function testHealthFactor() public {
        (, , , , , uint256 healthFactor) = ILendingPool(lendingPool).getUserAccountData(user);
        console.log("health factor", healthFactor);
        assertEq(healthFactor < 1 ether, true);
    }

I don’t know Solidity enought yet, so I wander what is the mining of that sequence of 5 commas?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Solidity allows you to return multiple values within a function. If you don’t need these values, you can omit them, and move to the next with the ,.

For example:

function returnStuff() public returns (uint256, uint256) {
   return (1, 3);
}

( , uint256 ourNum) = returnStuff();
// ourNum = 3
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading