how to make a filter on an array in Swift similar to like?

0

let cast = ["Vivien", "Marlon", "Kim", "Karl"]
would like to return like ('% ar%')
"expected result [" Marlon "," Karl "]"

    
asked by anonymous 25.07.2017 / 04:52

1 answer

0

You can use filter of the array to do this. Here's an example:

import Foundation
let castArray = ["Vivien", "Marlon", "Kim", "Karl"]
let filtered = castArray.filter { $0.containsString("ar") }
print(filtered)

I hope I have helped. Thanks!

    
31.08.2017 / 16:57