Next | Previous

type

Provides type validation and conversion capabilities

This module is wrapper around the builtin functions where applicable and does and return the same thing as the builtin alternative.

Functions

types.of(value)

Returns the name of the type of value

@notes:

  • method implemented as part of core language features
  • @params:
    • any value
  • @returns: string
types.digit(value)

Returns true if the value is a character and digit, otherwise returns false.

  • @params:
    • char value
  • @returns: bool
types.alpha(value)

Returns true if the value is a character and alphabetic, otherwise returns false.

  • @params:
    • char value
  • @returns: bool
types.int(value)

Returns true if the value is an integer or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.bool(value)

Returns true if the value is a boolean or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.number(value)

Returns true if the value is a number or false otherwise.

@notes:

  • this method also returns true for integers.
  • @params:
    • any value
  • @returns: bool
types.char(value)

Returns true if the value is a single character or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.string(value)

Returns true if the value is a string or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.bytes(value)

Returns true if the value is a bytes or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.list(value)

Returns true if the value is a list or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.dict(value)

Returns true if the value is a dictionary or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.object(value)

Returns true if the value is an object or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.function(value)

Returns true if the value is a function or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.is_a_class(value)

Returns true if the value is a class or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.file(value)

Returns true if the value is a file or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.iterable(value)

Returns true if the value is an iterable or false otherwise.

  • @params:
    • any value
  • @returns: bool
types.callable(value)

Returns true if the value is a callable function or class and false otherwise.

  • @params:
    • any value
  • @returns: bool
types.instance(value, type)

Returns true if the value is an instance the given class, false otherwise.

  • @params:
    • any value
    • class type
  • @returns: bool

Classes

class Convert

The Convert class handles conversion from one type to another

.Convert(value) ➝ Constructor

types.Convert constructor

  • @params:
    • any value
.to_int()

Converts the value into an integer.

@notes:

  • classes may override the return value by declaring a to_int() function.
  • @returns: bool
.to_number()

Converts the value into a number.

@notes:

  • classes may override the return value by declaring a to_number() function.
  • @returns: bool
.to_string()

Converts the value into a string.

@notes:

  • classes may override the return value by declaring a to_string() function.
  • @returns: bool
.to_bool()

Converts the value into a boolean.

@notes:

  • classes may override the return value by declaring a to_bool() function.
  • @returns: bool
.to_list()

Converts the value into a list.

@notes:

  • classes may override the return value by declaring a to_list() function.
  • @returns: bool
.to_dict()

Converts the value value into a dictionary.

@notes:

  • classes may override the return value by declaring a to_dict() function.
  • @returns: bool