T
T
The_XXI2021-03-28 21:12:50
Arrays
The_XXI, 2021-03-28 21:12:50

How to search by characters in an array of structures?

I have an array of structures. Each structure has a description, displaySymbol. How to search by characters? It is necessary to display all elements of the array whose description and/or displaySymbol contain the given symbols.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
briahas, 2021-03-28
@The_XXI

Why are you not satisfied with the function-

func filter(_ isIncluded: (Self.Element) throws -> Bool) rethrows -> [Self.Element]

Here is an example of usage. words.filter { word in return word.count >= 3 }
Or do you have a question about how to find a character in a string? - then use this string object function -func contains(_ element: Character) -> Bool

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question