#Is there a built-in `also` function that could be used for side-effects while piping?

1 messages ยท Page 1 of 1 (latest)

austere cliff
#

With a definition similar to:

fn also(value: a, side_effect: fn() -> b) -> a {
  side_effect()
  value
}

And used like this:

something 
|> also(fn() { my_side_effect() })
|> something_else()
crisp ember
#
pub fn function.tap(arg: a, effect: fn(a) -> b) -> a
austere cliff
#

Thank you!!

neon dew
#

we need @alias ๐Ÿ˜‰ - in elixir ut us called tap so i named it the same when i added it to stdlib ๐Ÿคทโ€โ™‚๏ธ

austere cliff
#

Heh, yeah coming from Kotlin I was expecting also

neon dew
#

yeah we need alias ๐Ÿ™‚

#

effect would also be a nice name i guess