In many programming languages (eg: JavaScript, Python, Java, C#, Clojure, etc.) you can use a negative index to select items in arrays or characters in text counting from the end of the array or string.
Positive indexes count from the start. Negative indexes count from the end.
So I tried this out in Coda and it works! At least for the Nth(), Slice(), Splice() and Left() functions.
Even though this feature is not included in the documentation.
Good to know! Hmm. Wouldn’t it be cool if the Coda documentation on formulas allowed us to add comments to them so they would know where updates were needed. Hmmm…
One more formula to add where I use negatives, Workday(). If you know the end date, or launch date, you can count backwards to the day you need to start by adding a negative to the number of workdays required. You can multiply by -1 but I thought it was kind of cool that you could go back and just add the minus sign next to a variable.
Hey @Agile_Dynamics this is great - I can use -1 to get the second to last item, but if I want to splice on to an existing array, is there a shortcut to get the last item in the array? I was hoping 0 would work, but no. -1+1 doesn’t work either. I know I could do [array].count() but looking for an easter egg.