Kotlin function reference

后端 未结 2 451
北海茫月
北海茫月 2021-01-12 05:13

Let records be stream/collection and extract function which transforms data form an element of such collection.

Is there a way in Kotlin to

2条回答
  •  心在旅途
    2021-01-12 05:43

    you could use method reference (similar to Java).

    records.map {::extract} 
    

    take a look at the function references examples on kotlin docs https://kotlinlang.org/docs/reference/reflection.html#function-references

提交回复
热议问题