Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

into bool for conversions

Convert value to boolean.

Signature

> into bool {flags} ...rest

Flags

  • --relaxed: Relaxes conversion to also allow null and any strings.

Parameters

  • ...rest: For a data structure input, convert data at the given cell paths.

Input/output types:

inputoutput
boolbool
intbool
list<any>table
nothingbool
numberbool
recordrecord
stringbool
tabletable

Examples

Convert value to boolean in table

> [[value]; ['false'] ['1'] [0] [1.0] [true]] | into bool value
╭───┬───────╮
│ # │ value │
├───┼───────┤
│ 0 │ false │
│ 1 │ true  │
│ 2 │ false │
│ 3 │ true  │
│ 4 │ true  │
╰───┴───────╯

Convert bool to boolean

> true | into bool
true

convert int to boolean

> 1 | into bool
true

convert float to boolean

> 0.3 | into bool
true

convert float string to boolean

> '0.0' | into bool
false

convert string to boolean

> 'true' | into bool
true

interpret a null as false

> null | into bool --relaxed
false

interpret any non-false, non-zero string as true

> 'something' | into bool --relaxed
true