Skip to content

Instantly share code, notes, and snippets.

@jigar23
Created June 23, 2018 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jigar23/5ba5131dc5a71ee39a3a31117256ee73 to your computer and use it in GitHub Desktop.
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=
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