Solidity version 0.1.6 - return multiple values

chrisethchriseth Member Posts: 170 ✭✭✭
edited October 2015 in Solidity
Solidity version 0.1.6 was just released containing the following new features:
  • push: You can use `x.push(7)` to append `7` to the end of a dynamically-sized storage array - it returns the new length.
  • tuples: You can use things like `return (1,2,3);` for a function returning three uints.
  • destructuring assignment: You can access multiple return values of a function by `var (x,y,z) = f();`, also `(data["abc"], x.a, z) = f();` is possible if the "variables" (lvalue expressions) on the left already exist.
  • destructuring assignment actually also supports wildcards: Some elements on the left can be missing which will throw away the respective value. If the first or the last element is missing, a prefix or suffix of the value tuple will be discarded.
These features are not yet documented in the tutorial, but will be shortly.

Furthermore, browser-solidity was also revamped, now supporting automatic import-dependency resolution by the backend compiler (only supported by most recent compiler versions), automatic library linking during deployment, compilation inside WebWokers (only on Firefox) as opposed to the main JavaScript thread and it can load source files directly from github:
import "github.com/ethereum/dapp-bin/library/features.sol"; import "github.com/pipermerriam/ethereum-grove/contracts/Grove.sol"; contract Test is mortal { GroveLib.Index bids; function Test() { GroveLib.insert(bids, "UNSET", 200); } function bid(uint value) { GroveLib.insert(bids, bytes32(msg.sender), int(value)); } function lowest() constant returns (address) { return address(GroveLib.query(bids, ">=", 0)); } }
You can directly try the code via this link.
Sign In or Register to comment.