Observable.just 访问多个参数

Observable.just Access multiple params

在下面的代码中,当我打印 s 时,我得到了作为 Observable.just 参数给出的第一个 String

Observable.just("Str1","Str2","str3")
    .map(new Func1<String, Object>() {
        @Override
        public Object call(String s) {
            System.out.println(s)
            return "test";
        }
    });

如何获取 call 方法中的其余参数??

Observable.just() 将发出传递的参数 one-by-one。您可以将它们包装在数组或 List 中以将它们视为单个对象:

String[] array = new String[] {"Str1", "Str2", "str3"};
Observable.just(array)
          .map(new Func1<String[], Object>() {
              @Override
              public Object call(String[] strings) {
                  return null;
              }
          });