代码之家  ›  专栏  ›  技术社区  ›  Uriel Arvizu

如何将翻新回调实例更改为Lambda表达式?

  •  0
  • Uriel Arvizu  · 技术社区  · 6 年前

    call.enqueue(new Callback<User>() {  
        @Override
        public void onResponse(Call<User> call, Response<User> response) {
            // todo deal with returned data (user)
        }
        @Override
        public void onFailure(Call<User> call, Throwable t) {
            // todo deal with the failed network request
        }
    });
    

    我试过以下方法:

    call.enqueue(
        (Call<User> call, Response<User> response) -> {
        // todo deal with returned data (user)
        },
        (Call<User> call, Throwable t) -> {
        // todo deal with the failed network request
    });
    

    在接口中找到多个非重写抽象方法 改造2.回拨

    用lambda表达式来表示这一点的正确方法是什么?将代码转换为lambda表达式的正确过程是什么?

    0 回复  |  直到 6 年前