Lambda parameters autocomplete

Suppose we have method like

public final static <T> Observable<T> create(OnSubscribe<T> f) {}

And an interface

public interface OnSubscribe<T> extends Action1<Subscriber<? super T>> {
    void call(T t);

When I’m trying to call create() method and pass OnSubscribe argument, Android Studio and IDEA doesn’t help with autocompletion of the arguments.

What I get is:

Observable.create<Unit> { }

Which basicaly means that I have to remember all the parameters needed to be passed to lambda, if I want to use them. I find this extremely inconvenient.
In Java, when I start typing “Observable.create(s” or “Observable.create(new”, I get hint about an argument.

What I (probably optionally) want to get in Kotlin is

Observable.create<Unit> { subscriber -> }

The interesting thing about this issue is that in some cases I can achieve this argument hint. For instance, when I start typing this:

alertDialog.setOnKeyListener { dialogInterface, i, keyEvent -> }

Can you please tell me the reason of this behavior?


Have the same issue

1 Like

Why? There is “it” implicit parameter for lambda with one parameter

Because “parameterName” is much more readable and easier to understand than just “it”.
Even so, there is no fast way to auto-introduce this “it” parameter with autocompletion.