From 1e068d34f4cb70c949aa7425c2b83169d745fd6b Mon Sep 17 00:00:00 2001 From: Dennis Brakhane Date: Sat, 28 May 2016 16:12:10 +0200 Subject: Add support for Python-like negative indexing Negative indexing is a useful feature in Python, especially when combined with array slicing. Array slicing will hopefully be implemented later, but negative indexing is useful in its own right. A negative index is indexing from the end of an array, "array[-1] == array[array.size()-1]", using a negative index larger/smaller than the length of the array is still an error. While primarily useful for arrays and strings, support is also added to "array like" structures like Vector3 and Color. This is done just to be consistent; vector3[2] is much clearer than vector3[-1], but disallowing it while allowing it for an array with 3 elements seems confusing. --- doc/base/classes.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/base/classes.xml b/doc/base/classes.xml index 8f29c7f166..d71918b949 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -4325,7 +4325,7 @@ Generic array datatype. - Generic array, contains several elements of any type, accessible by numerical index starting at 0. Arrays are always passed by reference. + Generic array, contains several elements of any type, accessible by numerical index starting at 0. Negative indices can be used to count from the right, like in Python. Arrays are always passed by reference. -- cgit v1.2.3