Skip to content

Conversation

@jstewmon
Copy link

@bosr
Copy link

bosr commented Apr 2, 2016

👍 yesss!

@shashankmehra
Copy link

Given [["one", 1], ["two", 2], ["one", 3]] what should be the output of from_items(@)?
Possible candidates could be: {"one": 1, "two": 2} or {"one": 3, "two": 2} or {"one": [1,3], "two": 2}

@jstewmon
Copy link
Author

@shashankmehra the last pair for any key will win, so in your example, the result will be:
{"one": 3, "two": 2}.

This is consistent with _.fromPairs in JavaScript:

> _.fromPairs([["one", 1], ["two", 2], ["one", 3]])
{ one: 3, two: 2 }

And dict construction in python:

>>> dict([["one", 1], ["two", 2], ["one", 3]])
{'two': 2, 'one': 3}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Let us select dict values by criteria on their associated keys

3 participants