Coming from the "old world", it looks a bit weird at first :)
Looking at |> addDays(2), I would expect addDays(2) to be evaluated before being used as a function. In my mind, this can only work if addDays(2) actually returns a function.
|> addDays(2)
addDays(2)
> In my mind, this can only work if addDays(2) actually returns a function.
This is what it does :)
A regular version of that function would look like that:
function addDays(amount, date) {...} addDays(2, date);
A curried version looks like that:
const addDays = amount => date => {...}; addDays(2)(date);
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Coming from the "old world", it looks a bit weird at first :)
Looking at
|> addDays(2)
, I would expectaddDays(2)
to be evaluated before being used as a function. In my mind, this can only work ifaddDays(2)
actually returns a function.> In my mind, this can only work if addDays(2) actually returns a function.
This is what it does :)
A regular version of that function would look like that:
A curried version looks like that: