Skip to content

Currying/Partials chapter #382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The task is a little more complex variant of <info:task/question-use-bind>.

The `user` object was modified. Now instead of two functions `loginOk/loginFail`, it has a single function `user.login(true/false)`.

What to pass `askPassword` in the code below, so that it calls `user.login(true)` as `ok` and `user.login(fail)` as `fail`?
What to pass `askPassword` in the code below, so that it calls `user.login(true)` as `ok` and `user.login(false)` as `fail`?

```js
function askPassword(ok, fail) {
Expand Down
4 changes: 2 additions & 2 deletions 1-js/06-advanced-functions/11-currying-partials/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ libs:

# Currying and partials

Till now we were only talking about binding `this`. Now let's make a step further.
Until now we have only been talking about binding `this`. Let's take it a step further.

We can bind not only `this`, but also arguments. That's rarely done, but sometimes can be handy.

Expand Down Expand Up @@ -148,7 +148,7 @@ More advanced implementations of currying like [_.curry](https://lodash.com/docs

```js
function curry(f) {
return function(..args) {
return function(...args) {
// if args.length == f.length (as many arguments as f has),
// then pass the call to f
// otherwise return a partial function that fixes args as first arguments
Expand Down