Skip to content

Introduce obtaining list of object's keys.#16

Open
mira01 wants to merge 1 commit intorjz:mainfrom
mira01:get_keys
Open

Introduce obtaining list of object's keys.#16
mira01 wants to merge 1 commit intorjz:mainfrom
mira01:get_keys

Conversation

@mira01
Copy link
Contributor

@mira01 mira01 commented Oct 19, 2021

No description provided.

{
"prompt": "Construct a list of all properties (keys) of a product",
"dataset": "product",
"solution": "to_entries | [.[].key]"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note keys as a built-in alternative!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both methods should return the same result, I think the to_entries is more general.
What do you think I should do with PR?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point (and while we're at it, add to_entries | map(.key) to the set of "valid" solutions—many right answers here!)

What we're showing here is basically the tutorial's "official" solution. We haven't (yet) formed strong opinions around presenting primitive v. higher-level features in this setting, but I think keys will be more practical for learners / new users. Let's show that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will set it this way. On the other side, my intention was to show the way to get names of keys to work on.

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.

2 participants