cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
Developer forum

Are GDL arrays 0 indexed?

Jack D
Booster

I'm asking this since my supervisor is always starts array at 1. 

 

DIM potato[]

   potato[1] = "russet"
   potato[2] = "yukon"
   potato[3] = "red lady"

To be honest, having 1 as the start of the index, kinda weirds me out but at the same time I'm also a bit curious if it is 0 indexed. Does this mean potato[0] does not exist or is potato[0] a none type?

1 ACCEPTED SOLUTION
3 REPLIES 3

Solution
DGSketcher
Champion

In GDL, arrays are always indexed from [1] or a 2D array would be [1][1]. Your example of potato[0] should throw up an invalid index warning when you check your script.

Apple iMac macOS Monterey / AC26UKI (most recent builds)

ahh thanks! I've been looking for some mention if it's 0 index in the pdf guide but got nothing. Which got me thinking.

Here are the details of using arrays: https://gdl.Graphisoft.com/reference-guide/expressions#DIM_gdlcommand

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!