Random

Why I don’t think type-hinted foreach loops are a good idea

There was a Twitter poll going around this morning that I thought was kind of interesting and got me thinking. It asked whether or not type-hinting in a foreach loop would be a good idea. The argument was that the same arguments that go for have type hinting in functions/methods apply to loops. Those reasons would primarily be structure. Having a more rigid structure means that the likelihood of a runtime error is lessened to a much greater degree. I agree with this statement, but I don’t think that it applies to loops. And here’s why.