Better Example of Key/Value pair iteration
@chipotle is already working on this.
Since Apr 22, 2016.
- Dominant language
- CSS
- Stars
- 118
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
Based on my recent experience coming up to speed on manipulating objects, I'd suggest that the following example should be included somewhere in the API docs. Had I seen it ... would have saved me a lot of time and a lot of head scratching:
r({"a": 1, "b": 2}).do(
(obj) => r.map(obj.keys(), obj.values(), (k, v) => [k, v]).coerceTo('OBJECT'))
I propose that this example be placed in the docs for map, because that's where I first went looking, trying to understand how I could iterate across all key/value pairs. Now, map does already have a tiny comment on this, but I missed it the first few times I looked, because my eye was drawn to the examples, and not the explanatory text.
Note: I personally find the following version harder to grok which is why I propose the version above:
r({"a": 1, "b": 2}).do(
(obj) => obj.keys().map(obj.values(), (k, v) => [k, v]).coerceTo('OBJECT'))
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.