<Prevent String.Contains from matching empty> I'm ...
# stackoverflow
u
Prevent String.Contains from matching empty I'm running a filter command on an object in kotlin and trying to match results. I didn't realize until today that an empty string will match any string in a contains query as follows: var brandname = "" var brandtofind = "tide" var result = brandtofind.contains(brandname) //results in true This is problematic when you are trying to match entries where a string can be empty as follows: var candidates = this.filter{ product -> text.contains(product.name) ||...