Hacker News new | ask | show | jobs
by xigoi 22 days ago
> i could definitely see this leading to some very funky looking chaining.

At least for me,

  thing
    .doThis()
    .thenDoThat()
    .andFinallyThis()
is much more readable than

  andFinallyThis(
    thenDoThat(
      doThis(thing)
    )
  )
2 comments

Yeah, this is the idea. This chaining is exactly the same as the pipeline operator in some some function languages, except that it hopefully reads in a more familiar way to programmers of non-functional languages.
Well, nesting is not the only option.

``` thing.doThis() thing.thenDoThat() thing.andFinallyThis()

// or

doThis(thing) thenDoThat(thing) andFinallyThis(thing) ```

That’s not equivalent.