How can i make Julia array index to start from zero 0 and not from one 1?

You can do this, as @Salmon says, but it is likely to cause you various issues, and also increases your chance of hitting bugs or trying to run code that only works for 1-based. Also, if you start using Tuples, or other specialized arrays, you end up back with 1-based.

I recommend just biting the bullet and using 1-based indexing. Most of the time, you don’t actually use them directly anyway. I mostly write code that uses firstindex, begin, eachindex, or simply

for val in arr
    # do something
end

You should never write

for i in 1:length(arr)
    #
end

anyway.

17 Likes