Fixing library examples that don't compile.

Addressing https://github.com/ethereum/solidity/issues/684
This commit is contained in:
Dave Hoover 2016-06-25 07:11:45 -05:00 committed by GitHub
parent b23c300792
commit b31bd4a2e4

View File

@ -883,8 +883,8 @@ custom types without the overhead of external function calls:
using BigInt for BigInt.bigint; using BigInt for BigInt.bigint;
function f() { function f() {
var x = bigint.fromUint(7); var x = BigInt.fromUint(7);
var y = bigint.fromUint(uint(-1)); var y = BigInt.fromUint(uint(-1));
var z = x.add(y); var z = x.add(y);
} }
} }
@ -986,7 +986,7 @@ Let us rewrite the set example from the
It is also possible to extend elementary types in that way:: It is also possible to extend elementary types in that way::
library Search { library Search {
function indexOf(uint[] storage self, uint value) { function indexOf(uint[] storage self, uint value) returns (uint) {
for (uint i = 0; i < self.length; i++) for (uint i = 0; i < self.length; i++)
if (self[i] == value) return i; if (self[i] == value) return i;
return uint(-1); return uint(-1);
@ -1004,8 +1004,8 @@ It is also possible to extend elementary types in that way::
function replace(uint _old, uint _new) { function replace(uint _old, uint _new) {
// This performs the library function call // This performs the library function call
uint index = data.find(_old); uint index = data.indexOf(_old);
if (index == -1) if (index == uint(-1))
data.push(_new); data.push(_new);
else else
data[index] = _new; data[index] = _new;