But we can skip the index if we need?
# announcements
k
But we can skip the index if we need?
s
return
should cause the calling function to return since the lambda isn’t marked as
crossinline
you should be able to
return@forEachIndexed
which will, essentially, break the “loop”
d
It will act like continue, not break.
k
But this just skip the index. Like if the condition passes on 5th index and I have
return@forEachIndex
it just skips the index 5 and continues with the next index i.e, 6th.
d
If you need true break and continue I suggest just using a normal for loop
Copy code
for ((index, value)  in list.withIndex()) {

}
a
takeWhile
/
takeUntil
?
👍 1
s
@corneil brings up a good point though - you might be misapplying imperative concepts to a functional construct
k
Yeah @diesieben07 is right!
Yeah I found the alternative ways but just that I wanted to know whether it can be done or not! By the way we can do it by both @corneil and @arekolek ways!