title: How to zip more than 8 mono using a combinator function
body: <p>I'm enriching data by calling multiple web services for each  item returned as the result of a previous webservice call (Ie - fanning out).</p>
  
  <p>I'm using Kotlin, Spring Boot 2 and the new reactive WebClient.</p>
  
  <p>In this snippet I'm showing just the code fanning out to the webservices, however in reality this is at the end of a larger pipeline. </p>
  
  <p>Previously I'd been using Mono.zip(t1, t2, t3) interface which supports passing up to 8 values and returns a tuple with the correct types.</p>
  
  <p>Definition: </p>
  
  <pre class="lang-java prettyprint-override"><code>    public static &lt;T1, T2, T3, T4, T5, T6, T7, T8&gt; Mono&lt;Tuple8&lt;T1, T2, T3, T4, T5, T6, T7, T8&gt;&gt; zip(Mono&lt;? extends T1&gt; p1,
              Mono&lt;? extends T2&gt; p2,
              Mono&lt;? extends T3&gt; p3,
              Mono&lt;? extends T4&gt; p4,
              Mono&lt;? extends T5&gt; p5,
              Mono&lt;? extends T6&gt; p6,
              Mono&lt;? extends T7&gt; p7,
              Mono&lt;? extends T8&gt; p8) {
          return onAssembly(new MonoZip(false, a -&gt; Tuples.fromArray((Object[])a), p1, p2, p3, p4, p5, p6, p7, p8));
      }
  </code></pre>
  
  <p>I now have more than 8 services to call so am looking at the Mono.zip(combinatorFn,  ... monos) method of combining the results of the calls. </p>
  
  <p>Definition:</p>
  
  <pre class="lang-java prettyprint-override"><code>    public static &lt;R&gt; Mono&lt;R&gt; zip(Function&lt;? super Object[], ? extends R&gt; combinator, Mono&lt;?&gt;... monos) {
          if (monos.length == 0) {
              return empty();
          }
          if (monos.length == 1) {
              return monos[0].map(d -&gt; combinator.apply(new Object[]{d}));
          }
          return onAssembly(new MonoZip&lt;&gt;(false, combinator, monos));
      }
  </code></pre>
  
  <p>My problem using <strong>KOTLIN</strong> I'm having difficulty defining the combinator function at the call site. Here is what I have so far: </p>
  
  <pre><code>val tst: (Array&lt;Any&gt;) -&gt; Mono&lt;AggregateReport&gt; = { it -&gt; Mono.just(AggregateReport("Test")) }
  
  
  val res = Mono.zip(
          tst,
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono(),
          Client.callThatReturnsAMono()
  )
  </code></pre>
  
  <p>Obviously I'd need to enhance the combinator to actually work with the input array and produce the aggregate. However the code doesn't currently compile. </p>
  
  <p>Compile error: </p>
  
  <pre><code>Error:(339, 41) Kotlin: Type mismatch: inferred type is (Array&lt;Any&gt;) -&gt; Mono&lt;ConsoleApplication.AggregateReport&gt; but Function&lt;in Array&lt;(out) Any!&gt;!, out (???..???)&gt; was expected
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p>Thanks!</p>