[Ethereum] How to get the return values

contract-developmentsolidity

I have a function with 4 return values which are in different types. Within the same contract, I want another function get this return values. For example,

function myFunction1() returns (uint, string, address){
       ......
}
funtion myFunction2(){
    String s = myFunction1();
}

I want string s get the second value returned by myFunction1. How can I do that?

Best Answer

See the section on "destructuring assignments and returning multiple values" in the Solidity documentation.

As an example:

    function f() returns (uint, bool, uint) {
        return (7, true, 2);
    }

    function g() {
        // Declares and assigns the variables. Specifying the type explicitly is not possible.
        var (x, b, y) = f();
    }

However, it should be noted that you can't return dynamically sized values, as per this previous answer.