Which version of foreach is the best/newest - 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)
+---- Forum: Discussion (
https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Which version of foreach is the best/newest (
/showthread.php?tid=637333)
Which version of foreach is the best/newest -
Eoussama - 12.07.2017
Hello there, hope you all doing great,
so I stumble across different scripts where I see people using a version of foreach where they use
PHP код:
foreach(Player, i)
the way I use it is
PHP код:
foreach(new i : Player)
so which one is the newest version if they are the same at all, and what's the deal with YSI\y_iterate?
Which one do you recommend?
Re: Which version of foreach is the best/newest -
Abagail - 12.07.2017
The second syntax is the newer version.
Re: Which version of foreach is the best/newest - Astralis - 12.07.2017
2nd all the way.
Re: Which version of foreach is the best/newest -
Eoussama - 12.07.2017
Quote:
Originally Posted by Astralis
2nd all the way.
|
Well the thing is, I recompiled my a script of mine accidentally without including foreach.inc or y_iterate.inc, the compiler gave no error, is it natively supported or what
Re: Which version of foreach is the best/newest -
Dayrion - 12.07.2017
Quote:
Originally Posted by Eoussama
Well the thing is, I recompiled my a script of mine accidentally without including foreach.inc or y_iterate.inc, the compiler gave no error, is it natively supported or what
|
Do you include other file from YSI? If yes, it's normal.
Re: Which version of foreach is the best/newest -
Eoussama - 12.07.2017
Quote:
Originally Posted by Dayrion
Do you include other file from YSI? If yes, it's normal.
|
I guess that must be it, I have y_timers.inc and y_hooks.inc included
Re: Which version of foreach is the best/newest -
Eoussama - 12.07.2017
Quote:
Originally Posted by ******
If you see code doing this, it is a good way to tell that the code has not been touched in literally 10 years and should probably just be ignored. That has not been the correct way to use foreach in a VERY VERY VERY long time!
|
This is ironic, I was literally just reading this
http://forum.sa-mp.com/showpost.php?...&postcount=320
so, including anything from YSI allow using foreach without having to include y_iterate? Like in my case?
Re: Which version of foreach is the best/newest -
Dayrion - 12.07.2017
Quote:
Originally Posted by Eoussama
|
Yes. For Y_Hooks, you need to include it in every file you use it.