about foreach - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: about foreach (
/showthread.php?tid=657829)
about foreach -
None1337 - 15.08.2018
Hello, I'm using most of the time the foreach include (I have the latest foreach/YSI library), and also I use iterators most of the time.
So.. I have 2 question:
1) What should I include foreach or y_iterate or both

?
Code:
#include <foreach>
or
#include <YSI\y_iterate>
2) How can I use both of the foreach syntax (old and the new/latest one) (is there a possible?)
foreach(Player, i)
foreach(new i : Player)
Sorry for my bad english..
Re: about foreach -
KinderClans - 15.08.2018
pawn Code:
foreach (new i : Player)
{
//Do your things.
}
Re: about foreach -
None1337 - 15.08.2018
Quote:
Originally Posted by KinderClans
pawn Code:
foreach (new i : Player) { //Do your things. }
|
I didn't correctly formulate the second question, I edited it. Sorry!
Re: about foreach -
GRiMMREAPER - 15.08.2018
1. If you're using iterators, as you've mentioned, you need to include
y_iterate.
2. Why not stick to one syntax? Needless to say, stick to the syntax of the latest version.
Re: about foreach -
Calisthenics - 16.08.2018
Quote:
Originally Posted by None1337
1) What should I include foreach or y_iterate or both  ?
Code:
#include <foreach>
or
#include <YSI\y_iterate>
|
foreach has not been updated for a LONG time, stick with y_iterate.
Quote:
Originally Posted by None1337
2) How can I use both of the foreach syntax (old and the new/latest one) (is there a possible?)
foreach(Player, i)
foreach(new i : Player)
Sorry for my bad english..
|
There is a reason the old syntax declared as 'deprecated' -- avoid using it. Besides, if you use latest version of y_iterate will give a warning instead!