This is an automated email from the ASF dual-hosted git repository.

hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new a5fbcfbb30 Update GroupBy doc: use idiomatic groupBy key function 
(#2795)
a5fbcfbb30 is described below

commit a5fbcfbb30e5bc75455ec9d81289502cdc42c509
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Sat Mar 28 17:05:05 2026 +0800

    Update GroupBy doc: use idiomatic groupBy key function (#2795)
    
    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.
---
 .../test/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 f2cd47c8e4..f6c5947700 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
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to