Hacker News new | ask | show | jobs
by nonameiguess 1912 days ago
tidyverse packages in R do this. Normally, you might have something like this:

    df = someFunctionThatReturnsADataFrame()
    newDf = someFunctionThatTakesAndReturnsADataFrame(df)
    doSomethingTo(df)
Since R lets you define your own operators, they took '%>%' and defined it as "pipe the return value from one function as the first argument to another function," so you can do this:

    someFunctionThatReturnsADataFrame() %>%
        someFunctionThatTakesAndReturnsADataFrame() %>%
        doSomethingTo()
No need to name either the temporaries or the function arguments.
1 comments

IRB the interactive ruby shell has _ which references the return value of the last command. So

10 + 10 puts _ # prints 20

but that isn't available in ruby itself