type - This function return the type of a variable.
variable.type() or type(variable)
The function return a string representation of the type of the specify variable.
See in example "Class special case" for how to handle Class types.
The following values can be return:
Primitive types
// Undefined variable check type(bar); // undefined foo.type(); // undefined // String check my_str = "Allo"; type(my_str); // string my_str.type(); // string // Integer check my_int = 12; type(my_int); // int my_int.type(); // int // Float my_flt = 1.2; type(my_flt); // float my_flt.type(); // float // Bool my_bool = true; type(my_bool); // bool my_bool.type(); // bool // Null my_null = null; type(my_null); // null my_null.type(); // null // Array my_arr = ["Allo", "Monde"]; type(my_arr); // array my_arr.type(); // array // Context my_ctx = {"att": "ribute"}; type(my_ctx); // context my_ctx.type(); // context // User function study function main() endf type(main); // user function main.type(); // user function // Language reserved word type(exec); // c function exec.type(); // c function
Class special case
class My_class method My_class(param) this.param = param; endm endc my_instance = new My_class("Allo"); type(my_instance); // class my_instance.type(); // WATCH OUT!! Sncode error page: "This method 'type' is not defined for class 'My_class'." // Class with method `type` defined class My_class method My_class(param) this.param = param; endm // Defined a function type method type() return classtype(this); endm endc my_instance2 = new My_class("Allo2"); my_instance.type(); // My_class <- DIFFERENT! type(my_instance); // class <- DIFFERENT!
2023-10-31 guillaume@sednove.com
Edit© 2024 extenso Inc. All rights reserved.