Skip to content

Support piping #44

@MagicMuscleMan

Description

@MagicMuscleMan

collect_as is clearly superior to collect in general. However, collect can easily be used in pipes with iterators due to its single argument method. I'd like to use collect_as in pipes, too, without the need to use lambdas.

I see the following possibilities, e.g. for Tuple

  1. add method collect_as(::Type{T}) which returns a callable to be used as
    1:3 |> collect_as(Tuple) .|> println
  2. add method collect_as_tuple(iterator) to be used as
    1:3 |> collect_as_tuple .|> println
  3. add a new function collect_tuple(iterator) to be used as
    1:3 |> collect_tuple .|> println

I think 1. is the most generic interface, has the advantage that no new export is needed, but blocks the single-argument method for future extensions (although it should be fine, I think).
I like 3. a bit more than 2. due to its brevity, which is nice in pipes, although I admit that 2. is less ambiguous.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions