9

I have a record {a:1, b:2}.

I would like to know how to get list of keys from it, which would return [a b] in this case.

0

1 Answer 1

9
{a:1, b:2} | columns

Not sure why I didn't notice columns initially. I just retested on 0.69.1 which was out when this question was asked and it works the same as my original answer below.

In the latest release (0.74), the corresponding/converse values has been added as well.


Old answer (still valid, but still non-optimal):

It's been a few weeks since I've used Nushell, so there's probably a better way that I'm missing. Quick (probably non-optimal) solution:

{a:1, b:2} | transpose | get column0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .