23.12.2013, 07:16
Nice, just a few things I'd like to point out:
1) For your example under "cells", you only need 61. 30 + 24 + 6 + 1. Though I don't think 9 cells has ever killed anyone.
2) Global variables (static or new) are only created once. The use of "static" for global variables is to restrict them to the file they were created in (useful for encapsulating libraries). Note that it can also be used the same for functions
Using "static" for local variables creates them once. They technically ARE global variables, they just don't clutter up the global namespace.
To summarize: Use "static" for functions/global variables to restrict them to the file they were created in. Use "static" for local variables that do not need to be constantly re-created (this is useful as they retain their previous value until overwritten).
3) For using the switch keyword, it should be noted the cases need be constant values.
Just as a note, "curls" are known as "loops".
1) For your example under "cells", you only need 61. 30 + 24 + 6 + 1. Though I don't think 9 cells has ever killed anyone.
2) Global variables (static or new) are only created once. The use of "static" for global variables is to restrict them to the file they were created in (useful for encapsulating libraries). Note that it can also be used the same for functions
pawn Code:
// function only accessible in the file it was created in
static stock HiddenFunc() {}
To summarize: Use "static" for functions/global variables to restrict them to the file they were created in. Use "static" for local variables that do not need to be constantly re-created (this is useful as they retain their previous value until overwritten).
3) For using the switch keyword, it should be noted the cases need be constant values.
Just as a note, "curls" are known as "loops".