if I make an array A_[01], can I refer to it later with A_[1]?

I am asking because I am not sure if this is the reason why I am getting some bugs.

  • 1
    \$\begingroup\$ I never used game maker, but in many programming languages, prefixing a number with a 0 means it's in octal format. \$\endgroup\$ – Philipp Dec 18 '16 at 23:32
  • 1
    \$\begingroup\$ Actually a valid question, some languages could treat such statement as hashmap with string keys... in which case there would be difference. \$\endgroup\$ – wondra Dec 18 '16 at 23:35
  • \$\begingroup\$ Yes, it's same. \$\endgroup\$ – Dmi7ry Dec 19 '16 at 6:39

I can't say confidently without testing myself, you should test yourself (see the bold below). However, reading the documentation on Data Types the following line is stated:

real numbers are any value that is not a string, nor any of the other possible data types.

The documentation makes no mention of octal literals, which is where 0 might be a prefix, and it doesn't make any mention of binary literal values. This documentation page mentions the only hexadecimal format relates to the $ character which is used for color values.

Note that you can also create colours from their hexadecimal value using the "$" symbol beforehand

Finally, this page on the arrays and their indexing has no mention of any special array indexing meaning. The data types like map appear to use functions rather than syntax to access the keys so I don't expect this to be an implicit map.

This leads me to conclude that if the GML parser reads a prefixed 0 as a real number, 02 should be equivalent to 2. You can test this theory by printing the result of 02 == 2, or put 02 into a variable and print the value, if it prints out as 2 it might be parsed as a real number. Note that I use 2 instead of 1 because if there is a binary literal somehow it won't translate.

I'd suggest you avoid relying on side effects (I'd consider this a side effect of the first quoted line) and be explicit: use the integer literal without the prefix to be sure and future proof.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.