toth:Now, when people talk derisively about the FOR-CASE paradigm, are they only referring to literal for() loops, or do foreach() loops follow under that umbrella, too? Because it seems like a FOREACH-CASE paradigm is actually ok. Of course, that may mean I'M TRWTF.
It depends. If you're programming in Perl, and the foreach loop looks like this:
foreach(my $i=1; $i<=2; $i++)
{
switch($i)
{
case 1 {
# do something
next; }
case 2 {
# do the next thing
next; }
}
}
Then not only is it wrong, but you're doing it more wrong than most people here could imagine (before this post, of course). Same goes for:
foreach $i (1..2)
{
switch($i)
{
case 1 {
# do something
next; }
case 2 {
# do the next thing
next; }
}
}
But, if the elements and/or order are uncertain, I think foreach-case may be ok.
tharpa:The "Reveal Codes" feature alone makes it better than Word.
QFT.