I'm trying to convert the following Java code to Kotlin in an idiomatic way:
for (Group group : groups) {
String groupName = group.getName();
if (groupName == null) {
warn("Group name is null for group " + group.getId());
continue;
}
...
}
I tried the following
for (group in groups) {
val groupName = group.name ?: run {
warn("Group name is null for group ${group.id}!")
continue
}
...
}
However this will not compile with the error:
'break' or 'continue' jumps across a function or class boundary
So my question is, is there a better way to write this in Kotlin?