无法删除 class 中定义的列表元素?
Can't remove list element defined inside class?
我似乎无法从 class 中定义的列表中删除元素:
class something {
List<int> numbers = [
70,
80,
90,
];
void PrintElementTwVo() {
print(numbers[2]);
}
void RemoveElement() {
PrintElementTwo(); // prints 80
numbers.remove(2); // should remove 80
PrintElementTwo(); // still prints 80 even after it got removed?
}
}
有人知道这是怎么回事吗?
我似乎无法从 class 中定义的列表中删除元素:
class something {
List<int> numbers = [
70,
80,
90,
];
void PrintElementTwVo() {
print(numbers[2]);
}
void RemoveElement() {
PrintElementTwo(); // prints 80
numbers.remove(2); // should remove 80
PrintElementTwo(); // still prints 80 even after it got removed?
}
}
有人知道这是怎么回事吗?