Created
June 23, 2018 19:43
-
-
Save jigar23/5ba5131dc5a71ee39a3a31117256ee73 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.23+commit.124ca40d.js&optimize=false&gist=
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity^0.4.10; | |
contract MultipleReturn { | |
function returnFirstValue(uint a, uint b) public pure returns (uint) { | |
return a; | |
} | |
function caller() public pure returns (uint) { | |
return returnFirstValue({a: 5, b: 10}); | |
} | |
function returnAllValues(uint a, uint b, uint c) public pure returns (uint, uint, uint) { | |
return (a,b,c); | |
} | |
function callerAll() public pure returns (uint, uint, uint) { | |
uint x; | |
uint y; | |
uint z; | |
(x,y,z) = returnAllValues({a:4, b:5, c:6}); | |
// Swap the values | |
(x,y) = (y,x); | |
(x,) = returnAllValues(5, 10, 15); | |
(,z) = returnAllValues(10, 20, 35); | |
return (x,y,z); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment