holgerbrandl
06/07/2016, 2:21 PMpublic class Test {
public static void main(String[] args) {
System.out.println("test" + 1);
System.out.println(1 + " test");
}
}
So Java seems to have some kind of fun Any?.plus(str:String)
@cy
Also the kotlin to java copy paste in intellij does not work for my example java-code.yole
06/07/2016, 2:21 PMyole
06/07/2016, 2:22 PMevanchooly
06/07/2016, 2:24 PMilya.gorbunov
06/07/2016, 2:25 PMAlso the kotlin to java copy paste in intellij does not work for my example java-code.@holgerbrandl: If you've got code behaving differently after doing Java-to-Kotlin conversion, please report an issue, so we could improve the converter.
yole
06/07/2016, 2:26 PMloganj
06/07/2016, 3:29 PMedvin
06/18/2016, 1:20 PMjohn.shelley
06/18/2016, 3:30 PMitems.forEachIndexed { i, item ->
if (item.flag? == true) {
// Do some logic then break/return because you found what you needed
return@forEachIndexed
}
}
Any help on why my return isn’t working?cedric
06/18/2016, 3:39 PMtakeWhile
here but I realize this doesn't answer your question)kirillrakhman
06/18/2016, 3:53 PMreturn@forEach
is equivalent to continue
. Wrap the whole code in a run {}
block and use return@run
john.shelley
06/18/2016, 4:25 PMrun {
items.forEachIndexed { i, libraryItem ->
if (libraryItem.uploadedAt?.after(sevenDaysAgo.time) == true) {
sections.add(AdapterSection(i, LAST_SEVEN_DAYS))
return@run
}
}
}
kirillrakhman
06/18/2016, 4:26 PMsreich
06/18/2016, 4:28 PMsreich
06/18/2016, 4:28 PMsreich
06/18/2016, 4:29 PMsreich
06/18/2016, 4:29 PMjohn.shelley
06/18/2016, 4:38 PMfor (i in 0..items.size() - 1) {
if (libraryItem.uploadedAt?.after(sevenDaysAgo.time) == true) {
sections.add(AdapterSection(i, LAST_SEVEN_DAYS))
break
}
}
sreich
06/18/2016, 6:17 PMsreich
06/18/2016, 6:17 PMsreich
06/18/2016, 6:17 PMsreich
06/18/2016, 6:17 PMsreich
06/18/2016, 6:18 PMsreich
06/18/2016, 6:18 PMsreich
06/18/2016, 6:21 PMsreich
06/18/2016, 6:24 PMsreich
06/18/2016, 6:29 PMkirillrakhman
06/18/2016, 7:27 PMindexOfFirst
kirillrakhman
06/18/2016, 7:36 PMval index = items.indexOfFirst { it.uploadedAt... }
sections.add(AdapterSection(index,... ))
max
06/18/2016, 9:52 PMrepeat(list.size()) { i -> .... }
instead of for (i in 0..items.size() - 1) { .. }
. It takes less symbols and has clear intention.