Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute Swift Online

func removeDuplicateInts(values: [Int]) -> [Int] {
    // Convert array into a set to get unique values.
    let uniques = Set<Int>(values)
    // Convert set back into an Array of Ints.
    let result = Array<Int>(uniques)
    return result
}

// Remove duplicates from these example numbers.
let numbers: [Int] = [10, 20, 20, 30, 40, 50, 10]
let uniqueNumbers = removeDuplicateInts(values: numbers)
print(numbers)
print(uniqueNumbers)

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.