File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -1216,6 +1216,36 @@ are available for both variable-sized and fixed-sized or variable-sized arrays.
12161216 let invalidIndices = example.slice(from: 2, upTo: 1)
12171217 ```
12181218
1219+ -
1220+ ``` cadence
1221+ fun reverse(): [T]
1222+ ```
1223+
1224+ Returns a new array with contents in the reversed order.
1225+ Available if ` T ` is not resource-kinded.
1226+
1227+ ``` cadence
1228+ let example = [1, 2, 3, 4]
1229+
1230+ // Create a new array which is the reverse of the original array.
1231+ let reversedExample = example.reverse()
1232+ // `reversedExample` is now `[4, 3, 2, 1]`
1233+ ```
1234+
1235+ ``` cadence
1236+ fun reverse(): [T; N]
1237+ ```
1238+
1239+ Returns a new fixed-sized array of same size with contents in the reversed order.
1240+
1241+ ```cadence
1242+ let fixedSizedExample: [ String; 3] = [ "ABC", "XYZ", "PQR"]
1243+
1244+ // Create a new array which is the reverse of the original array.
1245+ let fixedArrayReversedExample = fixedSizedExample.reverse()
1246+ // ` fixedArrayReversedExample ` is now ` ["PQR", "XYZ", "ABC"] `
1247+ ```
1248+
12191249#### Variable-size Array Functions
12201250
12211251The following functions can only be used on variable-sized arrays.
You can’t perform that action at this time.
0 commit comments