Skip to content

Commit

Permalink
Mention optional cell path members (nushell#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgwood committed Apr 22, 2023
1 parent fb6f555 commit 7eb3c04
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion book/types_of_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,19 @@ To remove rows from a table, you'll commonly use the [`select`](/commands/docs/s
╰───┴───┴───┴───╯
```
There are numerous other commands for selecting and reducing the data in tables, records and lists.
#### Optional cell paths
By default, cell path access will fail if it can't access the requested row or column. To suppress these errors, you can add `?` to a cell path member to mark it as _optional_:
```sh
> [{foo: 123}, {}].foo?
╭───┬─────╮
│ 0 │ 123 │
│ 1 │ │
╰───┴─────╯
```
When using optional cell path members, missing data is replaced with `null`.
## Closures
Expand Down Expand Up @@ -465,5 +477,7 @@ Error: nu::shell::column_not_found
╰────
```
If you would prefer this to return `null`, mark the cell path member as _optional_ like `.1.a?`.
The absence of a value is (as of Nushell 0.71) printed as the ❎ emoji in interactive output.
:::

0 comments on commit 7eb3c04

Please sign in to comment.