Skip to content
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

_.memoize: Show default hash function in Docs #137

Closed
DTrejo opened this issue Mar 3, 2011 · 1 comment
Closed

_.memoize: Show default hash function in Docs #137

DTrejo opened this issue Mar 3, 2011 · 1 comment

Comments

@DTrejo
Copy link

DTrejo commented Mar 3, 2011

After playing around with _.memoize, I see that the default hash function is

// Note that _.memoize hashes only the first argument by default.
function(arg1) {
  return arg1;
}

It would be cool if the docs mentioned this.

I'll send a pull request when I have a moment to fork+edit.

Thanks for making a super useful library!
-David

@jashkenas
Copy link
Owner

Sure thing:

d71f480

albemuth pushed a commit to albemuth/underscore that referenced this issue May 4, 2011
roryokane added a commit to roryokane/underscore that referenced this issue Sep 17, 2013
With a comment, document the nonobvious behavior of _.identity in this context.

I wrote this comment to accompany the following sentence from [the current docs for `_.memoize`](http://documentcloud.github.io/underscore/#memoize):

> The default **hashFunction** just uses the first argument to the memoized function as the key.

I looked in the code, but couldn’t see how that was the case. The code quoted in [Issue jashkenas#137](jashkenas#137) was no longer there. I wondered if that sentence in the documentation was out-of-date. It took me a while to notice that the use of `apply` over `call` changed `_.identity` from returning `arguments` to returning the first argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants