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?
>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