I am trying to rewrite a leisure project from Java to Kotlin (in order to understand it), and I have encountered some problems. Research led me to { function() } but that didn't help me
In Java, I have this interface:
public interface Shuffling<T> { List<T> shuffle(List<T> list, ShuffleCallback callback); interface ShuffleCallback { void onShuffle(int addedTo, int randomIndex); } }
And I'm trying to add a test object to the list of shuffling algorithms in Kotlin:
val algoList = ArrayList<Shuffling<Int>>() algoList.add(Shuffling { list, callback -> { Timber.d("Test!") ArrayList<Int>() // how to return this value? }})

How to add multiple lines to lambda function?
I also have another example of problems:
Kotlin Interface:
interface Drawable { fun draw() }
And the Kotlin implementation:
private val drawList = ArrayList<Drawable>()

I used to just use:
mDrawList.add(() -> glDrawArrays(GL_TRIANGLE_FAN, startVertex, numVertices));
And everything was in order.
source share