Top Posts

how to profit from bitcoin mining msi bios update 64 bit best bang for your buck video card story of casper the friendly ghost pci e 1x graphics card radeon drivers for windows 7 pci express slot graphics card is mining bitcoins worth it windows 7 registry tweaks download bitcoin mining rate of return how to make your own custom rom what is the purpose of the 4 pin molex connector ecoin card code and password display driver amd driver stopped is mining bitcoins worth it molex to pcie 6 pin dalhousie university halifax ns canada the richest nation in africa pcie 3 video card in pcie2 slot different types of sata cables 4 pin molex to 8 pin how to install developer tools mac undefined reference to pthread create difference between gold and bronze power supply pci express x16 extension cable sata to 4 pin power adapter pci e 1x graphics card convert bitcoin to usd paypal sapphire r9 290 tri x 4 pin molex to 6 pin ubuntu 14.04 vs windows 8.1 linux zip command not found gigabyte radeon r9 280x oc

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Multiple return values from a function

crayons610crayons610 Member Posts: 11
I could get a solidity function like:
foo() returns(uint bar, uint baz) {}
to compile, but I couldn't figure out how to access the return values when the function is called.
Are multiple return values legal & how to access them pls?


  • lefterislefteris Member Posts: 7
    Multiple returns values are not yet implemented. The syntax for declaration of a function with multiple return values is there but that's all for now. It's a pending TODO item.
  • chrisethchriseth Member Posts: 170 ✭✭✭
    The return values should be "sent to the wire", though, i.e. they should be part of the "return value" if it is a message call.
  • crayons610crayons610 Member Posts: 11
    I found multiple returns by accident, I think a leftover from a prior serpent attempt.
    Will be a nice feature though.

  • chrisethchriseth Member Posts: 170 ✭✭✭
    By the way, the plan is to allow something like this in Solidity:
    (a, b, c) = f();
  • oomooomo Member Posts: 31
    Do we know if multi-value return supported now in Solidity? Due to the lack of support of returning struct, this will be extremely helpful. Currently, we end up defining getter() per field in struct. This multiple return could be pushed out to JSONRPC returning an JSON.
  • chrisethchriseth Member Posts: 170 ✭✭✭
    edited June 2015
    Note that returning multiple values was supported from the start. The only thing that is not supported is accessing more than one returned value after a call to another contract. This here works:
    contract c {
    struct s { uint a; uint b; string d; }
    s data;
    function f() returns (uint a, uint b, string d) {
    a = data.a;
    b = data.b;
    d = data.d;
    Post edited by StephanTual on
  • oomooomo Member Posts: 31
    @chriseth First, can you please elaborate on "accessing more than one returned value after a call to another contract"? Secondly, can you show on example in JavaScript on how would I fetch this multiple values? I read somewhere that it is returned as an array? It would have been nice if this was returned as a JSON
  • chrisethchriseth Member Posts: 170 ✭✭✭
    edited June 2015
    On "accessing more than one returned value": Given the above contract, in the following code, x will be of type uint and only contain the "a"-part of the return values of f.
    contract c2 {
     c otherContract;
     function g() {
     var x = otherContract.f();
  • jwgcarlylejwgcarlyle Member Posts: 29
    Is there any progress on the capability
    (a, b, c) = f();
    that was outlined earlier? In my use-case, I want to have an internal function that can return a couple of values to a calling code block, so the comments above about a call to another contract don't apply.

    I'd be happy to keep track of the backlogged item, if it's easier to post a link.
  • chrisethchriseth Member Posts: 170 ✭✭✭
    It is now possible to return a struct from an internal function, so that can be used as a work-around for now.

    The story is here:
or to comment.