I have `foo: String` and `bar: List<String>`...
# getting-started
j
I have
foo: String
and
bar: List<String>
. What's a clever way to return true if
foo
starts with (or I guess
contains
works too) at least one string in
bar
?
Obviously I can write a simple function for this, but I'm wondering if there's any cool kotlin library stuff. I can't seem to find anything that does exactly this
k
bar.any { it.startsWith(foo) }
2
j
Awesome, just what I was looking for. Thanks!
j
val fooInBar = bar.find { it.contains(foo) }
?
1