This site requires JavaScript, please enable it in your browser!
Greenfoot back
Pointifix
Pointifix wrote ...

2014/3/9

Variable Names using?

Pointifix Pointifix

2014/3/9

#
Hi guys, i wanted to know what variable names you use for nested for loops. The first variable i always use is "i" for index, but which variable do you use then? cause i want my variable names always having sense for what they are doing ;)
danpost danpost

2014/3/9

#
I think 'i' is something that kind of 'stuck' from back in the days when it was standard to start variable names with a specific set of letters depending on the type of variable it was ('i' was the first letter for integers). I still use 'i', 'j', and 'k' myself.
Pointifix Pointifix

2014/3/9

#
i,j,k mhhmm just cause they are near on your keyboard? the names does not have any meaning any more then.
danpost danpost

2014/3/9

#
Pointifix wrote...
i,j,k mhhmm just cause they are near on your keyboard? the names does not have any meaning any more then.
No. Because they come consecutively in the alphabet. A through H were for alphas and I through Z were for numbers. But , as far as not having any meaning any more, I would say they still do. 'x' and 'y' for coordinates; 'w' and 'h' for height and width; 'v' for velocity; 'i', 'j', 'k' for counters one, two and three; etc. Replacing them with more descriptive names would not hurt, however.
You need to login to post a reply.