Since Kotlin 1.1, you can use bound callable references to do that:
val f = a::getItem
list.forEach(myObject::myMethod)
Earlier Kotlin versions don’t have this feature and require you to make a lambda every time except for these simple cases.
More Related Contents:
- Using return inside a lambda?
- Passing lambda instead of interface
- Zipping streams using JDK8 with lambda (java.util.stream.Streams.zip)
- What is a lambda (function)?
- Use of lambda for cons/car/cdr definition in SICP
- How to create an instance of anonymous interface in Kotlin?
- Lazy field initialization with lambdas
- Alan Kay’s Eval/Apply Einstein Moment
- Do Java8 lambdas maintain a reference to their enclosing instance like anonymous classes?
- Kotlin: Use a lambda in place of a functional interface?
- Lambda implementation of interface in kotlin
- lambda expression to sort on min values in a group
- How can I throw CHECKED exceptions from inside Java 8 streams?
- NullPointerException when trying to access views in a Kotlin fragment
- maven. lambda expressions are not supported in -source 1.5
- Parallel stream from a HashSet doesn’t run in parallel
- How to make primary key as autoincrement for Room Persistence lib
- Kotlin Android start new Activity
- Execution failed for task ‘:app:mapDebugSourceSetPaths’. > Error while evaluating property ‘extraGeneratedResDir’ of task
- Linq – Top value from each group
- ViewTreeLifecycleOwner not found from DecorView@2da7146[MyActivity]
- AsyncTask as kotlin coroutine
- Get the property name used in a Lambda Expression in .NET 3.5
- Cannot use Java 8 method with lambda arguments without specifying type arguments
- Creating String representation of lambda expression [duplicate]
- Lambda function syntax in JavaScript without curly braces
- How to pass id and application to a viewModel/viewModelFactory in Jetpack Compose?
- Using Include in Entity Framework 4 with lambda expressions
- How to implement timer with Kotlin coroutines
- When can we omit the return type in a C++11 lambda?