Skip to content

java-stream-append-prepend article needs minor correction #12930

@GeoffChurch

Description

@GeoffChurch
    Hi @lor6, I think the article still needs a minor update.

It says

In this case, since the stream is not consumed greedily, it is still partially lazy

The new approach is actually fully lazy, so you can e.g. insert an element at index 3 billion in constant time.

Also, the conclusion says

Keep in mind that although prepending an element works for any Stream, adding it to the end or at a specific index only works for finite streams.

This sentence can probably be removed because inserting at a specific finite index now works for any Stream, and it does technically work to append to the end of an infinite stream, you just wouldn't reach the element after a finite number of steps.

Originally posted by @GeoffChurch in #10931 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    on-jiratriagedIssues reviewed by a dev and considered valid. Will be added in Jira.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions