Migrating from fast 3 to fast 4 - Cannot convert String to expected String.Element

I convert my code from swift 3 to swift 4 and get this error in the following code. I get this even when I try to use flatmap to align the array

Cannot convert a String value to the expected argument type 'String.Element' (otherwise a character)

if favoritedProducts.contains("helloWorld") {}

The bottom line of code does not return [String], but is "[String.Element]". How do I convert it to [String]. If I try to use it as [String], it says that it always fails.

let productIDs = allItems.flatMap{$0.productID}
+6
source share
1 answer

Item productID String,

struct Item {
    let productID: String
}

Item

let allItems: [Item] = ...

productID(s) map

let productIDs = allItems.map { $0.productID }

productIDs [String].

+3

All Articles