I'm trying to call individual values from another function, without storing those values to the contract. Here is my complete code:
pragma solidity ^0.4.23; contract Test { function setThreeValues() public view returns(int, uint, uint) { int x = 5; uint y = 7; uint z = 0; x += 5; y += 13; z = uint(x) + y; return (x, y, z); } function callThreeValues() public view returns(int, uint, uint) { return setThreeValues(); } // function callX() public view returns(int) { // return setThreeValues(int); // } // function callY() public view returns(uint) { // return setThreeValues(uint); // } // function callZ() public view returns(uint) { // return setThreeValues(uint); // } }
when I run my function callThreeValues
, I get all three values I'm expecting, which is 10, 20, 30.
However with my three further functions (callX, callY, callZ)
, I can't seem to get them to work....
with callX I'm trying to call the first value (10)
with callY I'm expecting to call the second value (20)
with callZ I'm expecting to call the third value (30)
I've obviously got the syntax wrong in my code, but I can't figure out how to get these functions working.
Sorry it's such a noob question!
Any help would be much appreciated :-)
setThreeValues(int)
... Hint: you're not supposed to pass a type to a function (certainly when it doesn't expect any input arguments!!!).