From 7b662d578bf05a0976083894d8b9a2d4acb8348b Mon Sep 17 00:00:00 2001 From: He-Pin Date: Sat, 28 Mar 2026 04:36:02 +0800 Subject: [PATCH] Update GroupBy doc: use idiomatic groupBy key function Change groupBy key from '_ % 2 == 0' (Boolean) to '_ % 2' (Int) for a more idiomatic example. Add note about non-deterministic mergeSubstreams output ordering. Upstream: akka/akka-core@1ed6dc09fd Cherry-picked from akka/akka-core v2.8.0, which is now Apache licensed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../scala/docs/stream/operators/sourceorflow/GroupBy.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/src/test/scala/docs/stream/operators/sourceorflow/GroupBy.scala b/docs/src/test/scala/docs/stream/operators/sourceorflow/GroupBy.scala index f2cd47c8e4f..f6c5947700a 100644 --- a/docs/src/test/scala/docs/stream/operators/sourceorflow/GroupBy.scala +++ b/docs/src/test/scala/docs/stream/operators/sourceorflow/GroupBy.scala @@ -22,12 +22,13 @@ object GroupBy { implicit val system: ActorSystem = ??? // #groupBy Source(1 to 10) - .groupBy(maxSubstreams = 2, _ % 2 == 0) // create two sub-streams with odd and even numbers + .groupBy(maxSubstreams = 2, _ % 2) // create two sub-streams with odd and even numbers .reduce(_ + _) // for each sub-stream, sum its elements .mergeSubstreams // merge back into a stream .runForeach(println) - // 25 - // 30 + // 30 (even: 2+4+6+8+10) + // 25 (odd: 1+3+5+7+9) + // Note: output order may vary since mergeSubstreams is non-deterministic // #groupBy }