modules/gdscript/tests/scripts/parser/features/array.gd
raw| 1 | func test(): |
| 2 | # Indexing from the beginning: |
| 3 | print([1, 2, 3][0]) |
| 4 | print([1, 2, 3][1]) |
| 5 | print([1, 2, 3][2]) |
| 6 | |
| 7 | # Indexing from the end: |
| 8 | print([1, 2, 3][-1]) |
| 9 | print([1, 2, 3][-2]) |
| 10 | print([1, 2, 3][-3]) |
| 11 | |
| 12 | # Float indices are currently allowed, but should probably be an error? |
| 13 | print([1, 2, 3][0.4]) |
| 14 | print([1, 2, 3][0.8]) |
| 15 | print([1, 2, 3][1.0]) |
| 16 | print([1, 2, 3][-1.0]) |