-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does anArray.length-- delete the last element? #4802
Comments
Yes, it will |
Ok, I learned two interesting things today.
Yesterday I thought I am working now to update the documentation. PR coming. Here are the black box test cases: pragma solidity ^0.4.23;
contract Array {
uint[] public numbers;
function length() external view returns (uint) {
return numbers.length;
}
function numbers() external view returns (uint[]) {
return numbers;
}
function inc() external {
numbers.length++;
}
function dec() external {
numbers.length--;
}
function plusOne() external {
numbers.length = numbers.length + 1;
}
function plusALot() external {
numbers.length = numbers.length + 2**20;
}
function minusOne() external {
numbers.length = numbers.length - 1;
}
function minusALot() external {
numbers.length = numbers.length - 2**20;
}
function pushOne() external {
numbers.push(1);
}
function setSizeToTen() external {
numbers.length = 10;
}
/*
function pop() external {
numbers.pop();
}
*/
} |
Documentation fix added at be74b6d |
Normally I send questions to StackOverflow.
But here I see an assertion that calling
.length--
on an array will delete the last element and recover gas.The people on that team are generally smart so I'm going to assume it is true.
If it is true then can the documentation please be update to explain this feature?
The text was updated successfully, but these errors were encountered: