Fix bug in Array::insert.

This commit is contained in:
Stephen Chung
2021-01-29 22:29:36 +08:00
parent 903b6d6795
commit bb925a697c
2 changed files with 9 additions and 8 deletions

View File

@@ -29,7 +29,7 @@ macro_rules! gen_array_functions {
pub fn insert(list: &mut Array, position: INT, item: $arg_type) {
if position <= 0 {
list.insert(0, Dynamic::from(item));
} else if (position as usize) >= list.len() - 1 {
} else if (position as usize) >= list.len() {
push(list, item);
} else {
list.insert(position as usize, Dynamic::from(item));