Home Explore Blog CI



nushell

8th chunk of `book/types_of_data.md`
f22be1fa6120b203394db9f9824f773d6b2c0072c95fdab10000000100000c90
The table is a core data structure in Nushell. As you run commands, you'll see that many of them return tables as output. A table has both rows and columns.

:::tip
Internally, tables are simply **lists of records**. This means that any command which extracts or isolates a specific row of a table will produce a record. For example, `get 0`, when used on a list, extracts the first value. But when used on a table (a list of records), it extracts a record:

```nu
[{x:12, y:5}, {x:3, y:6}] | get 0
# => ╭───┬────╮
# => │ x │ 12 │
# => │ y │ 5  │
# => ╰───┴────╯
```

:::

## Other Data Types

### Any

|                       |                                                                                                             |
| --------------------- | ----------------------------------------------------------------------------------------------------------- |
| **_Description:_**    | When used in a type annotation or signature, matches any type. In other words, a "superset" of other types. |
| **_Annotation:_**     | `any`                                                                                                       |
| **_Literal syntax:_** | N/A - Any literal value can be assigned to an `any` type                                                    |
| **_See also:_**       | [Language Reference - Any](/lang-guide/chapters/types/basic_types/any.md)                                   |

### Blocks

|                       |                                                                               |
| --------------------- | ----------------------------------------------------------------------------- |
| **_Description:_**    | A syntactic form used by some Nushell keywords (e.g., `if` and `for`)         |
| **_Annotation:_**     | N/A                                                                           |
| **_Literal Syntax:_** | N/A                                                                           |
| **_See also:_**       | [Language Reference - Block](/lang-guide/chapters/types/other_types/block.md) |

Simple example:

```nu
if true { print "It's true" }
```

The `{ print "It's true" }` portion above is a block.

### Nothing (Null)

|                       |                                                                                   |
| --------------------- | --------------------------------------------------------------------------------- |
| **_Description:_**    | The `nothing` type is to be used to represent the absence of another value.       |
| **_Annotation:_**     | `nothing`                                                                         |
| **_Literal Syntax:_** | `null`                                                                            |
| **_See also:_**       | [Language Reference - Nothing](/lang-guide/chapters/types/basic_types/nothing.md) |

#### Simple Example

Using the optional operator `?` returns `null` if the requested cell-path doesn't exist:

```nu
let simple_record = { a: 5, b: 10 }
$simple_record.a?
# => 5
$simple_record.c?
# => Nothing is output
$simple_record.c? | describe
# => nothing
$simple_record.c? == null
# => true
```

Title: Nushell Data Types: Any, Blocks, and Nothing (Null)
Summary
This section describes three Nushell data types: 'Any', 'Blocks', and 'Nothing'. 'Any' matches any type in annotations. 'Blocks' are syntactic forms used by keywords like 'if' and 'for'. 'Nothing' represents the absence of a value and is represented by 'null'.