1
orgList.getOrgMigrationMap().entrySet().stream()
    .filter(//some logic)
    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

Trying to get the Kotlin equivalent of this code, but looks like double colon :: in Kotlin means something else than Java. Can someone suggest?

Mehdi Rahimi
  • 1,453
  • 5
  • 20
  • 31
Denise
  • 898
  • 1
  • 16
  • 30
  • https://kotlinlang.org/docs/collection-filtering.html#filter-by-predicate – Nikolai Shevchenko May 20 '22 at 09:05
  • They're called "method references" in Java, so went to the Kotlin docs linked above and typed "method references" into the search box there. The list included a topic called "[function references](https://kotlinlang.org/docs/reflection.html#function-references)" which seems to suggest you use much the same syntax. – T.J. Crowder May 20 '22 at 09:10
  • This nice post covers many already existing stdlib functions in Kotlin which are equivalent to Java stream intermediate/terminal operations. [what-java-8-stream-collect-equivalents-are-available-in-the-standard-kotlin-libr](https://stackoverflow.com/questions/34642254/what-java-8-stream-collect-equivalents-are-available-in-the-standard-kotlin-libr) – Eritrean May 20 '22 at 09:24
  • Does this answer your question? [Kotlin: Method reference not working?](https://stackoverflow.com/questions/32598320/kotlin-method-reference-not-working) – knittl May 20 '22 at 09:44

1 Answers1

1

it's the same but it can also be used to get reflection information about the target source.

Emma
  • 431
  • 6
  • 19