2Dcube
Member
I love the "var" keyword but wonder how it should be used.
For example, I often declare it before using it in a loop:
But is this necessary? (Actually "i" is not declared before hand so it's inconsistent)
The below is faster to write. Is there a reason not to? The manual didn't seem clear on this but seemed to encourage declaring before a loop.
Does this reserve a different part of memory each time?
(Does it even make a difference at all?)
For example, I often declare it before using it in a loop:
Code:
var item;
for(var i=0; i<ds_list_size(items); i++)
{
item = items[| i];
do_something_with(item);
}
The below is faster to write. Is there a reason not to? The manual didn't seem clear on this but seemed to encourage declaring before a loop.
Code:
for(var i=0; i<ds_list_size(items); i++)
{
var item = items[| i];
do_something_with(item);
}
(Does it even make a difference at all?)