Skip to content

A Source.SplitAfter Akka example extra output #3222

@vasily-kirichenko

Description

@vasily-kirichenko

I'm trying to port an example from https://doc.akka.io/docs/akka/snapshot/stream/stream-substream.html

use system = ActorSystem.Create("test")
let mat = system.Materializer()

let text = "This is the first line.\nThe second line.\nThere is also the 3rd line\n"

Source.From(text.ToCharArray())
    .SplitAfter(fun x -> x = '\n')
    .Where(fun x -> x <> '\n')
    .Select(fun _ -> 1)
    .Aggregate(0, fun s x -> s + x)
    .To(Sink.ForEach(fun x -> Console.WriteLine (sprintf "%A" x)))
    .Run(mat)
    |> ignore
       
Console.ReadKey() |> ignore

As the docs says, it should output

23
16
26

but it outputs

26
0
16
23

Where does the 0 come from?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions