I've run into some odd behavior of solidity. In the following example:
// Omit corner cases for brevity
contract C {
address[] addrList;
function addAddr(address addr) {
addrList.push(addr);
}
function deleteAddr(address addr) {
for(uint256 i = 0; i < addrList.length; i++) {
if(addr == addrList[i]) {
for(uint256 j = i; j < addrList.length; j++) {
addrList[j] = addrList[j + 1];
}
delete addrList[addrList.length - 1];
addrList.length--; // <== This gives Error: Expression has to be an lvalue.
}
}
}
}
it cannot resize the length of the array once the value has been deleted. Why can't the length of the address array be decremented?
Deleting integers from an integer array is possible.