That's a bit like saying the difference between George Bush and George W Bush is only the W. After all, you can use George Bush to refer to either one.
But they really are different people! They're not the same!
And that's the same with for/foreach. They are not the same! There's a for loop, and there's a foreach loop, and you can use the word "for" or "foreach" to refer to either one, but they are not the same.
| [reply] |
If you can show me a single instance in which the use of "for" instead of "foreach" makes a difference in code, I'll believe you.
| [reply] |
Do you mean the word for exchanged for the word foreach? No. Those keywords are syntactically equivalent. And I don't disagree with that fact.
Do you mean replace a for loop with a foreach loop, or vice versa? Certainly! They have different semantics!
The keyword "for" is the same as the keyword "foreach". The "for" loop is different from the "foreach" loop. Do I need to keep repeating this? {sigh}
| [reply] |