Home Explore Blog CI



nushell

1st chunk of `book/types_of_data.md`
6d2ee1cb2436aff6cbf523a3d8b94cb329d89fb60265ded80000000100001012
# Types of Data

Traditional Unix shell commands communicate with each other using strings of text -- One command writes text to standard output (often abbreviated `stdout`) and the other reads text from standard input (or `stdin`). This allows multiple commands to be combined together to communicate through what is called a "pipeline".

Nushell embraces this approach and expands it to include other types of data in addition to strings.

Like many programming languages, Nu models data using a set of simple, structured data types. Simple data types include integers, floats, strings, and booleans. There are also special types for dates, file sizes, and time durations.

The [`describe`](/commands/docs/describe.md) command returns the type of a data value:

```nu
42 | describe
# => int
```

## Types at a Glance

| Type                                  | Example                                                               |
| ------------------------------------- | --------------------------------------------------------------------- |
| [Integers](#integers)                 | `-65535`                                                              |
| [Floats (decimals)](#floats-decimals) | `9.9999`, `Infinity`                                                  |
| [Strings](#text-strings)              | <code>"hole 18", 'hole 18', \`hole 18\`, hole18, r#'hole18'#</code>   |
| [Booleans](#booleans)                 | `true`                                                                |
| [Dates](#dates)                       | `2000-01-01`                                                          |
| [Durations](#durations)               | `2min + 12sec`                                                        |
| [File-sizes](#file-sizes)             | `64mb`                                                                |
| [Ranges](#ranges)                     | `0..4`, `0..<5`, `0..`, `..4`                                         |
| [Binary](#binary-data)                | `0x[FE FF]`                                                           |
| [Lists](#lists)                       | `[0 1 'two' 3]`                                                       |
| [Records](#records)                   | `{name:"Nushell", lang: "Rust"}`                                      |
| [Tables](#tables)                     | `[{x:12, y:15}, {x:8, y:9}]`, `[[x, y]; [12, 15], [8, 9]]`            |
| [Closures](#closures)                 | `{\|e\| $e + 1 \| into string }`, `{ $in.name.0 \| path exists }`     |
| [Cell-paths](#cell-paths)             | `$.name.0`                                                            |
| [Blocks](#blocks)                     | `if true { print "hello!" }`, `loop { print "press ctrl-c to exit" }` |
| [Null (Nothing)](#nothing-null)       | `null`                                                                |
| [Any](#any)                           | `let p: any = 5`                                                      |

## Basic Data Types

### Integers

|                       |                                                                                                                                                           |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **_Description:_**    | Numbers without a fractional component (positive, negative, and 0)                                                                                        |
| **_Annotation:_**     | `int`                                                                                                                                                     |
| **_Literal Syntax:_** | A decimal, hex, octal, or binary numeric value without a decimal place. E.g., `-100`, `0`, `50`, `+50`, `0xff` (hex), `0o234` (octal), `0b10101` (binary) |
| **_See also:_**       | [Language Reference - Integer](/lang-guide/chapters/types/basic_types/int.md)                                                                             |

Title: Data Types in Nushell
Summary
Nushell uses structured data types like integers, floats, strings, booleans, dates, file sizes, and durations. The 'describe' command identifies a value's type. The document further lists all data types with examples, including integers, floats, strings, booleans, dates, durations, file-sizes, ranges, binary, lists, records, tables, closures, cell-paths, blocks, null, and any. It also explains integers in detail, including their description, annotation, and literal syntax.