forEach – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 10: Line 10:
  }
  }
Obviously, the facts listed in the article is untrue. we should either make additional comments or remove this statement.
Obviously, the facts listed in the article is untrue. we should either make additional comments or remove this statement.
:>> In ArmA2, the variable _x is always local to the foreach block so it is safe to nest foreach commands.
Heh:
_log = [];
{
    {
        _log set [count _log, _x]
    } foreach ["a", "b", "c"];
    _log set [count _log, _x]
} foreach [1,2,3];
_log
in ofp, arma and arma2 this code returns the result:
["a","b","c",1,"a","b","c",2,"a","b","c",3]

Revision as of 09:35, 5 April 2010

DenV 09:25, 5 April 2010 (CEST)

>> Plural commands are executed within one frame, so this command might cause performance loss when used on very large arrays or with very complex commands.

Heh, in this case, you have to explain why this code is functional:

0 spawn { 
    {
        player sideChat str _x; 
        sleep 1 
    } foreach [1,2,3] 
}

Obviously, the facts listed in the article is untrue. we should either make additional comments or remove this statement.

>> In ArmA2, the variable _x is always local to the foreach block so it is safe to nest foreach commands.

Heh:

_log = [];
{ 
    { 
        _log set [count _log, _x] 
    } foreach ["a", "b", "c"]; 
    _log set [count _log, _x] 
} foreach [1,2,3]; 
_log

in ofp, arma and arma2 this code returns the result:

["a","b","c",1,"a","b","c",2,"a","b","c",3]