79583649

Date: 2025-04-20 18:45:57
Score: 1.5
Natty:
Report link

I've come up with my own solution, which seems a bit cleaner than the one proposed by @david-soroko.

fun <T> Iterable<T>.javaForEach(consumer: Consumer<T>) = forEach(consumer)

The main point here is that the Iterable.forEach takes a Consumer, Kotlin's forEach takes a lambda and explicitly passing the Consumer resolves to the java forEach.
And just changing forEach to javaForEach looks cleaner than always casting.

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @david-soroko
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: binarynoise