rest-param.ts 409 B

12345678910
  1. // Rest parameter must gather EVERY actual past its position: joinAll(a, b) binds
  2. // parts = [a, b], so both ask#1 and ask#2 reach ask#3 through `...parts`.
  3. function joinAll(...parts: string[]): string {
  4. return parts.join(" ");
  5. }
  6. const a = await agent("a").ask<string>("A");
  7. const b = await agent("b").ask<string>("B");
  8. const r = joinAll(a, b);
  9. const c = await agent("c").ask<string>(`use ${r}`);
  10. return c;