array.gd 368 B

12345678910111213141516
  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. # Indexing from the end:
  7. print([1, 2, 3][-1])
  8. print([1, 2, 3][-2])
  9. print([1, 2, 3][-3])
  10. # Float indices are currently allowed, but should probably be an error?
  11. print([1, 2, 3][0.4])
  12. print([1, 2, 3][0.8])
  13. print([1, 2, 3][1.0])
  14. print([1, 2, 3][-1.0])