Is there a way to perform initialization before fo...
# getting-started
s
Is there a way to perform initialization before forEach and cleanup after forEach only for a non-empty list?
Copy code
list.filter {}.also { // one time init if it.isNotEmpty() }.forEach {}.also { //final cleanup but size of list is not known directly }