Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
thedev11717yTechnically, second rule is not a rule is a direct consequences of the 1st rule. You know the rule number 0.
-
@thedev Yeah but it's appropriate because 1 (The index of the second item) is one less than the length of the list.
-
thedev11717y@AlgoRythm the index of the first item is already one less than the length. Because it starts at 0.
-
Kaylum1457yYou could use something like Lua. Granted, you then have the problem that you're using Lua, but you'll like the arrays!
-
Salmakis6737yThe Element of Index 0 ends where 1 begins, so the length thing makes sense. If there is 1 element that starts @0 (ends @1) then then len is 1.
-
zshh38487yWhy does it confuse you? If you know it starts at index 0 then the end must be length - 1.
-
@simeg It's mostly for the joke man, but sometimes it is a little confusing when applying it to data structures and not counting the normal way.
-
But they don't start at 0. They just index starting from zero. It can sometimes get confusing tho, whether you should add 1, subtract 1, just leave it, etc.
There are two things about arrays that sometimes confuse me:
[0]: They start at zero
[1]: They end at one less than the length
undefined