Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

how to remove item from list swift

var animals = ["cats", "dogs", "chimps", "moose"]

// remove at specific index
animals.remove(at: 2)  //["cats", "dogs", "moose"]

// remove first element
animals.removeFirst() //["dogs", "moose"]

// remove last element
animals.removeLast() //["dogs"]

// remove at unknown index
if let index = animals.firstIndex(of: "dogs") {
    animals.remove(at: index)
}

Comment

PREVIOUS NEXT
Code Example
Swift :: for loop swift 
Swift :: swift make condition that you are in sumulator 
Swift :: wkwebview load delegate in swift 
Swift :: swift repeating array 
Swift :: swft image 
Swift :: swift get current hour 
Swift :: swift convert string to int 
Swift :: check notification permission ios swift 
Swift :: swift add two arrays 
Swift :: case insensitive multiple word search swift 
Swift :: initialize array with zero in swift 
Swift :: deselect all cell in collectionview 
Swift :: and or in swift 
Swift :: convert secondsfrom1970 to date swift 
Swift :: swift enum xib 
Swift :: Convert JSON to Data 
Swift :: clothes that you wear in Diwali 
Swift :: how to limit ui field in ios 
Swift :: Swift Weak Reference 
Swift :: editbutton swiftui color text 
Swift :: Swift Function With inout Parameters 
Swift :: cherries 
Swift :: Swift Arithmetic Operators 
Swift :: image copy swift extension 
Swift :: swift 5 full screen image viewer 
Swift :: dynamic table view height without scrolling 
Swift :: spilit string in swift 
Swift :: how to add two right bar button item xcode 
Ruby :: ruby string to date 
Ruby :: ruby memory location 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =