11

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.

NotTheDr01ds
  • 28,025

1 Answers1

12
{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
Kissaki
  • 773
NotTheDr01ds
  • 28,025