Oleh Ponomarenko
02/12/2019, 1:13 PMfor (it in this.list) {
                if (it == example) {
                    //do smth
                    break
                }
            }
In Kotlin I use:
this.list.foreach{
    if(it==example) //do smth
}
I can't use "break" in foreach. I get an error: "Break & continue is only allowed inside a loop".marstran
02/12/2019, 1:14 PMreturn@foreachOleh Ponomarenko
02/12/2019, 1:16 PMOleh Ponomarenko
02/12/2019, 1:22 PMmarstran
02/12/2019, 1:22 PMrun to make that scope. run {
  listOf(1,2,3,4,5).forEach {
    if (it == 3) return@run
    print(it)     
  }
}marstran
02/12/2019, 1:23 PMOleh Ponomarenko
02/12/2019, 1:23 PMOleh Ponomarenko
02/12/2019, 1:24 PMmarstran
02/12/2019, 1:29 PMrun loop@ label.Oleh Ponomarenko
02/12/2019, 1:34 PMUzi Landsmann
02/12/2019, 1:53 PMJake
02/12/2019, 2:29 PMthis.list.filter{ it == example }.apply { ... }
 to do the same thing.Oleh Ponomarenko
02/12/2019, 2:45 PMOleh Ponomarenko
02/12/2019, 2:46 PMmarstran
02/12/2019, 2:46 PMfind.aarjav
02/12/2019, 4:18 PMShawn
02/12/2019, 4:22 PMfor (item in list) foreach loop not acceptable now?Shawn
02/12/2019, 4:23 PMfirst() or find() is more appropriate for this particular use case but nothing wrong with using regular ol’ loops in Kotlin when you need toaarjav
02/12/2019, 4:23 PMOleh Ponomarenko
02/12/2019, 4:24 PMShawn
02/12/2019, 4:26 PMforEach at the end of a functional chain is fine, but is still really only geared towards cases where you’re okay with applying your transform to every element of whatever iterable you’re working onSOFe
02/13/2019, 3:56 AMfor (it in this.list) it is Kotlin too... In both Java and Kotlin you still have forEach too...