Why arrays start from 0?

Why “position” value of ListView component always starts from 0?
When we use it for something else or with other components it becomes confusing sometime.

Like if we use it with airtable, I select item from the list and then I use (position) number to update my value in airtable. If I select first item, it’s value according to ListView will be 0 and that will give me error in airtable. If I select second item from ListView, it (ListView) count it as 1, now if I use this number it will update my first value instead of second in airtable.

This announces that you’re a developer! :nerd_face: :sweat_smile:

Set Global Variable to 1

Yeah, I can also use other tricks to do that, but I just want to know Why “position” value of ListView component always starts from 0? :sweat_smile:

Use add block from math category.

From google search

This means that the index is used as an offset. The first element of the array is exactly contained in the memory location that array refers ( 0 elements away), so it should be denoted as array[ 0 ]. Most programming languages have been designed this way, so indexing from 0 is pretty much inherent to the language .


But it is not working properly when using it with other apps.
Some starts value with 1 (like airtable) and some with 0 (like ListView)

Add +1 to the ListView index when clicking

I am doing that
I am just mentioning here that I figured it out myself but it takes lot of my time. But for some other user (maybe a newbie) this will just confuse him or his app will never work properly.

Airtable is a database, so that’s why it starts counting from 1.
And programming languages are starts counting from 0.

This is a known rule, and cannot be changed. Even Kodular changes the ListView thing, most programming languages will still count starting from 0.

1 Like

When you are born, you are born with 0 years. The first birthday is Year 1
Note this does not apply to Korea, were people’s years are counted from 1 and not from 0 :sweat_smile:

Also, if you are not from USA, you will see that elevators/lift count the ground floor as 0, and not as 1, even though it is a floor as well
Elevators in USA start counting from 1 from the lowest level

There are plenty of things which start counting at 0, and arrays is one of them


thx for replying everyone :blush:

I created this post for others. In future if someone having a similar problem, he can find a working solution here.

1 Like

I found one more situation like this, now in same component.
In Tab Layout Component, I choose a specific tab at position 1, but when I use select tab block and join math block “1” it select tab at position 2 instead of 1.

‘Tab Layout’ does not follows it.
Its index starts from 1 not from 0

You have solved your own question: position
Position there refers to a real position, not to an array position

So now we can summarize this topic.
This topic tells us two important functions.
Position starts from 1 ,while
Array starts from 0

1 Like

Oh nice
Ok that means when we load something in a list, it loads with “position” which starts from 1
but when we select values from that list, it select values with “array” which starts from 0?

Only for some components like list view image and text but not for all like tab layout.
I think someone should make a guide on position and arrays.

1 Like

yes someone should bcoz there are lots of components
and some of them use position and some use array

If you could that would be great. :+1: