Skip to content

Instantly share code, notes, and snippets.

@MohamedGouaouri
Created April 14, 2023 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MohamedGouaouri/da15555872fc2ee404324b806ea44d20 to your computer and use it in GitHub Desktop.
Save MohamedGouaouri/da15555872fc2ee404324b806ea44d20 to your computer and use it in GitHub Desktop.
fun MutableList<Restaurant>.search(
query: String
): MutableList<Restaurant>{
val result = mutableListOf<Restaurant>()
this.forEach {restaurant ->
if (restaurant.title.contains(query, ignoreCase = true) || restaurant.description.contains(query, ignoreCase = true)){
result.add(restaurant)
}
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment