-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdestructing.sol
34 lines (34 loc) · 1.02 KB
/
destructing.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
contract FunctionOutputs
{
//Functions can return multiple outputs.
function returnManyOutputs() public pure returns(uint, bool)
{
return(1,true);
}
//outputs can be named
function nameOutput() public pure returns(uint number,bool Myboolstatus)
{
return(1,true);
}
// outputs can be assigned to their name.
// here return ststement can be omiittted.
function AssignedOutput() public pure returns(uint number, bool Myboolstatus)
{
number=1;
Myboolstatus=true;
}
// Use Destructuring assignment when calling another
// function that returns multiple outputs.
function DestructuringAssignments() public pure
{
(uint number, bool Myboolstatus) = returnManyOutputs();
// Outputs can be left out.
(bool Myanotherboolstatus) = returnManyOutputs();
}
function Samplefunction() external view returns(address,bool)
{
return (msg.sender,true);
}
}