Skip to main content
Skip to main content

to

Source code

This file contains functions for converting a value to a specific type

Index

to::string

Convert a value to a string

Example

to::string 1 # 1

Arguments

  • $1 (any): value

Output on stdout

  • The value as a string

to::boolean

Convert a value to a boolean

Example

to::boolean "true"  # 1
to::boolean "false" # 0
to::boolean "hi" # 1

Arguments

  • $1 (any): value

Output on stdout

  • The value as a boolean

to::int

Convert a value to an integer

Example

to::int "1" # 1
to::int "a" # error

Arguments

  • $1 (any): value

Exit codes

  • 1: If the value is not an integer

Output on stdout

  • The value as an integer

to::float

Convert a value to a float

Example

to::float "1.1" # 1.1
to::float "a" # error

Arguments

  • $1 (any): value

Exit codes

  • 1: If the value is not a float

Output on stdout

  • The value as a float

to::stdin

Convert the value '-' to stdin

Example

to::stdin "a" # a
to::stdin "-" # (stdin)

Arguments

  • $1 (any): value

Output on stdout

  • The value or stdin

to::file

Check if a value is a file

Example

to::file "a" # error
to::file "file.txt" # file.txt

Arguments

  • $1 (any): value

Exit codes

  • 1: If the value is not a file
Was this section helpful?