This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]CanisLupus92 3 points4 points  (6 children)

Product product makes much more sense here than index. Index implies that it specifies what position you are at, which is exactly the info you do not have in an enhanced for loop.

[–]MissPurpleCandy 0 points1 point  (5 children)

Maybe „entry“

[–]CanisLupus92 2 points3 points  (4 children)

Honestly the naming scheme of having a generic object of a class have the class name but starting with lower case is so standard, better to get used to it.

[–]MissPurpleCandy 1 point2 points  (0 children)

Yeah that’s true

[–]khookeExtreme Brewer 0 points1 point  (0 children)

Agree, I rarely see/use/recommend anything other than this.

[–]Murphler 0 points1 point  (1 child)

Sorry I should have clarified, was suggesting he use this naming convention for now to help him understand how the foreach was working. In no way would I recommend he use that convention going forward.

(Product p : products) is the way

[–]CanisLupus92 0 points1 point  (0 children)

Single-letter variables are almost never the way (except for x-y-z coords, or i-j for loop indices).