The modern and fun way to program.
std.castThe box std.cast is an utility to convert into and
check object types.
int (x)Casts the object x to an integer.
It does work only if x is an integer, float or a string.
Returns the integer, or null if x is of an incompatible type.
float (x)Casts the object x to a float.
It does work only if x is an integer, float or a string.
Returns the float, or null if x is of an incompatible type.
string (obj)Converts object obj to a string.
If obj is an instance, it has to have a method named to_string().
Returns the string.
is_int (x)Returns true if x is an integer, false otherwise.
is_float (x)Returns true if x is a float, false otherwise.
is_string (x)Returns true if x is a string,
false otherwise.
uchar (cp)Returns a string containing the character represented by the Unicode codepoint cp, or null if cp is not a valid codepoint.
ucode (str)Returns the Unicode codepoint of the first character in the string str, or null if str is not a valid string.
value (x)Returns x. If x is a reference, returns the object pointed by x.
typeof (obj)Returns a string representing the type of the object obj following the rules:
| Object Type | Output String |
|---|---|
| Null | n |
| Integer | i |
| Float | f |
| String | s |
| Class instance | o |
| Enum | e |
| Class | c |
| Function | F |
| Method | m |
| Box | b |
| Reference | r + type |
| Instance Creator | I |
| Native Data | d |
| Other | u |
classof (obj)Returns the class of the object obj, or null if obj is neither a class instance nor a string.
baseof (c[, n = 0])Returns the nth super class of the class c, or null if c is not a class or has not that super class.
same (a, b)Returns true if a and b are the same object, false otherwise.
kin (c1, c2)Returns true if class c2 is derived from or the same as class c1. c1 and c2 can be also class instances, in that case their base classes will be used instead (see classof()).
desc (obj)Returns a string containing a description of obj (such as <null> for null,
<integer> for integer, etc.). The description given are equal to them printed by
Smudge error messages.
| Home |