So I hav a List<String> of values like "net"...
# announcements
o
So I hav a List<String> of values like "net" and "com". And I have a function where I have to iterate over this list and return a boolean whenever the value of the list matches a string. How do I do this? perhaps onEach can help, but idk how to implement that.
g
Copy code
val list: List<String> = someList()
val isAnyOfValuesTrue = list.any { it.validateAndReturnBool() }
☝️ 1
h
list.joinToString() == givenString
If you're working with urls, you can pass separator = '.' to joinToString to make it look like string. (list.joinToString(separator = '.') == givenString)
s
Or if you wish to match each element of the list with an String:
Copy code
val targetString = "something"
val anyMatches = listOf("net", "com").any { it == targetString }