solidity-ide
solidity-ide copied to clipboard
[Language] functions as parameters
The following example is valid code, that should result in a single compiler warning "Naming function type return parameters is deprecated.". We currently don't support functions as parameter
pragma solidity ^0.4.18;
contract test{
function reduce(uint[] memory self, function (uint x, uint y) returns (uint) f) internal returns (uint r)
{
r = self[0];
for (uint i = 1; i < self.length; i++) {
r = f(r, self[i]);
}
}
}