Array Remove

From SwiftAPI

Jump to: navigation, search

Removes the first occurrence of a value from an array. Also see Array Remove element for removing all occurrences of a value.

For languages that are not shown below, you can equivalently perform this operation by first finding the index of the desired element using Array Index Of, and then removing it using Array Remove At using the index.

Java

For Lists:

import java.util.*;
 
List<Integer> a = new ArrayList<Integer>(Arrays.asList(9, 4, 0, 4, 3));
a.remove((Integer)4);
// a == [9, 0, 4, 3]

For arrays this doesn't make sense since arrays are fixed sized.

Python

a = [9, 4, 0, 4, 3]
a.remove(4)
# a == [9, 0, 4, 3]
Personal tools