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
- @params:
- types.alpha(value)
-
Returns true if the value is a character and alphabetic, otherwise returns false.
- @params:
- char value
- @returns: bool
- @params:
- types.int(value)
-
Returns true if the value is an integer or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.bool(value)
-
Returns true if the value is a boolean or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- 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
- @params:
- types.string(value)
-
Returns true if the value is a string or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.bytes(value)
-
Returns true if the value is a bytes or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.list(value)
-
Returns true if the value is a list or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.dict(value)
-
Returns true if the value is a dictionary or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.object(value)
-
Returns true if the value is an object or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.function(value)
-
Returns true if the value is a function or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.is_a_class(value)
-
Returns true if the value is a class or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.file(value)
-
Returns true if the value is a file or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.iterable(value)
-
Returns true if the value is an iterable or false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.callable(value)
-
Returns true if the value is a callable function or class and false otherwise.
- @params:
- any value
- @returns: bool
- @params:
- types.instance(value, type)
-
Returns true if the value is an instance the given class, false otherwise.
- @params:
- any value
- class type
- @returns: bool
- @params:
Classes
- class Convert
-
The Convert class handles conversion from one type to another
- .Convert(value) ➝ Constructor
-
types.Convert constructor
- @params:
- any value
- @params:
- .to_int()
-
Converts the value into an integer.
@notes:
- classes may override the return value by declaring a
to_int()
function.
- @returns: bool
- classes may override the return value by declaring a
- .to_number()
-
Converts the value into a number.
@notes:
- classes may override the return value by declaring a
to_number()
function.
- @returns: bool
- classes may override the return value by declaring a
- .to_string()
-
Converts the value into a string.
@notes:
- classes may override the return value by declaring a
to_string()
function.
- @returns: bool
- classes may override the return value by declaring a
- .to_bool()
-
Converts the value into a boolean.
@notes:
- classes may override the return value by declaring a
to_bool()
function.
- @returns: bool
- classes may override the return value by declaring a
- .to_list()
-
Converts the value into a list.
@notes:
- classes may override the return value by declaring a
to_list()
function.
- @returns: bool
- classes may override the return value by declaring a
- .to_dict()
-
Converts the value value into a dictionary.
@notes:
- classes may override the return value by declaring a
to_dict()
function.
- @returns: bool
- classes may override the return value by declaring a