Loading...
In this smart book, we will discuss how to return multiple values in any function.
In this example, we define multiple two-variable those stored different values my name and my age.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.5 <0.9.0;
contract MyContract {
string name = 'Anurag';
uint age = 21;
function multipleReturn() public view returns(string memory, uint){
return (name, age);
}
}
Define a function that gives public visibility means anyone can access within a contract or outside the contract. In returns they've two parameters one is a string type and the other is uint. It defines the same data type which you want to return.