M
mdbussen
Guest
... Is there really no way to tell if a given variable is an integer value or a data structure? This seems insane to me. I ran into this issue when I was working on a save system for my game and it is bizarre. Given the following code:
The output to the console is:
(Note that the last two checks are different just because I happen to be using ds_map but not ds_priority in my project).
Is there any way to tell the difference between an integer value and a data structure???
Code:
var this_map = ds_map_create();
show_debug_message("this_map is a " + typeof(this_map));
ds_map_destroy(this_map);
var this_list = ds_list_create();
show_debug_message("this_list is a " + typeof(this_list));
ds_list_destroy(this_list);
var this_grid = ds_grid_create(2,2);
show_debug_message("this_grid is a " + typeof(this_grid));
ds_grid_destroy(this_grid);
var this_queue = ds_queue_create();
show_debug_message("this_queue is a " + typeof(this_queue));
ds_queue_destroy(this_queue);
var this_stack = ds_stack_create();
show_debug_message("this_stack is a " + typeof(this_stack));
ds_stack_destroy(this_stack);
var this_priority = ds_priority_create();
show_debug_message("this_priority is a " + typeof(this_priority));
ds_priority_destroy(this_priority);
var this_int = 1;
show_debug_message("is this_int a ds_map? " + (ds_exists(this_int, ds_type_map) ? "yes!" : "no"));
var this_int = 1;
show_debug_message("is this_int a ds_priority? " + (ds_exists(this_int, ds_type_priority) ? "yes!" : "no"));
Code:
this_map is a number
this_list is a number
this_grid is a number
this_queue is a number
this_stack is a number
this_priority is a number
is this_int a ds_map? yes!
is this_int a ds_priority? no
Is there any way to tell the difference between an integer value and a data structure???