Skip to content

Imperative pipelines (“tap” operators) #741

@usaoc

Description

@usaoc

Some languages provide pipeline operators or alike for use with imperative functions/methods:

  • Clojure provides doto that works like ->, except that each forms are evaluated and discarded, and the original value is returned. For example, (doto (new java.util.HashMap) (.put "a" 1) (.put "b" 2)) initiates a Java mutable hash table (see the ClojureDocs page).
  • In Kotlin, .apply (with receiver) and .also (with argument) are available as extension methods on objects (see Kotlin scope functions).
  • (Unfortunately, I couldn’t find a precedent on a .- or |>-like tap operator.)

This operation is also known as “tap” or “tee”. Is this a useful addition to Rhombus?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions