Welcome Guest, Not a member yet? Register   Sign In
Can/should a switch be declared in a foreach loop
#6

[eluser]Relexx[/eluser]
It is generally considered that if switch (or similar control structure) is available the its use is preferable to a long list of if elseif, elseif, ... statements (in some languages elseif is not available either). Underlying it may be performing almost the same code. Multiple elseif's may be preferable if you are dealing with sub ranges (eg 1-5, 6-10, ...) opposed to unique values (even with the former if the ranges were uniform then you could do some math to generate a uniform value).


Messages In This Thread
Can/should a switch be declared in a foreach loop - by El Forum - 02-17-2009, 02:58 PM
Can/should a switch be declared in a foreach loop - by El Forum - 02-17-2009, 04:11 PM
Can/should a switch be declared in a foreach loop - by El Forum - 02-17-2009, 04:13 PM
Can/should a switch be declared in a foreach loop - by El Forum - 02-17-2009, 04:20 PM
Can/should a switch be declared in a foreach loop - by El Forum - 02-17-2009, 05:06 PM
Can/should a switch be declared in a foreach loop - by El Forum - 02-17-2009, 10:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB