Created
February 9, 2021 19:22
-
-
Save aleksandr-lavrinenko/c495dae9dbb7b6033b981128e37ec4a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct Content { | |
| let title: String | |
| let description: String | |
| } | |
| fileprivate extension Array where Element == Content { | |
| func filter(text: String) -> [Content] { | |
| let trimmedText = text.trimmingCharacters(in: .whitespacesAndNewlines) | |
| return filter { | |
| $0.title.range(of: trimmedText, options: .caseInsensitive) != nil | |
| || $0.description.range(of: trimmedText, options: .caseInsensitive) != nil | |
| } | |
| } | |
| } | |
| let content = Content(title: "fsdfs", description: "sfdfs") | |
| [content].filter(text: "fs") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment