Ternary operator in a foreach loop
#11

Since foreach is a macro, it might effect the variable names and so one since "define" is just a text replacement.


example:
PHP Code:
#define iter:%1<%2> \
    
%1limit = %2

#define myLoop(%1,%2) \
    
for (new %1; %< %2limit; %1++)

main()
{
    new 
iterTEST<10>;
    
myLoop(iTEST)
    {
    }

    new 
iterTEST2<10>;
    
myLoop(i, (random(2) ? (TEST) : (TEST2))) // this wont work because the macro\'s "%2limit" will become "(random(2) ? (TEST) : (TEST2))limit" which makes no sense
    
{
    }

So an "if" statement is what have to use.
Reply


Messages In This Thread
Ternary operator in a foreach loop - by Cypress - 12.03.2017, 22:03
Re: Ternary operator in a foreach loop - by ISmokezU - 12.03.2017, 22:21
Re: Ternary operator in a foreach loop - by Cypress - 12.03.2017, 22:24
Re: Ternary operator in a foreach loop - by Unte99 - 12.03.2017, 22:35
Re: Ternary operator in a foreach loop - by Cypress - 12.03.2017, 22:47
Re: Ternary operator in a foreach loop - by Pottus - 12.03.2017, 22:52
Re: Ternary operator in a foreach loop - by Cypress - 12.03.2017, 22:55
Re: Ternary operator in a foreach loop - by Pottus - 12.03.2017, 22:58
Re: Ternary operator in a foreach loop - by Cypress - 12.03.2017, 23:03
Re: Ternary operator in a foreach loop - by Pottus - 12.03.2017, 23:53
Re: Ternary operator in a foreach loop - by Gammix - 13.03.2017, 00:44

Forum Jump:


Users browsing this thread: 1 Guest(s)