Skip to content

Commit a29deb6

Browse files
authored
add at and sort methods for StaticArray (#103)
1 parent a2b18f7 commit a29deb6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/stdlib/staticarray.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ The StaticArray API is similar to the [Array API](./array.md), with the importan
4343

4444
### Methods
4545

46+
* ```ts
47+
function at(pos: i32): T
48+
```
49+
Gets the element at the specified position. This method allows for positive and negative integers. Negative integers count back from the last element.
50+
4651
* ```ts
4752
function concat(other: T[]): T[]
4853
```
@@ -73,6 +78,11 @@ The StaticArray API is similar to the [Array API](./array.md), with the importan
7378
```
7479
Returns a shallow copy of this static array's values from `begin` inclusive to `end` exclusive, as a new normal array. If omitted, `end` defaults to the end of the array.
7580

81+
* ```ts
82+
function sort(fn?: (a: T, b: T) => i32): this
83+
```
84+
Sorts the values of the array in place, using the specified comparator function, modifying the array before returning it. The comparator returning a negative value means `a < b`, a positive value means `a > b` and `0` means that both are equal. Unlike in JavaScript, where an implicit conversion to strings is performed, the comparator defaults to compare two values of type `T`.
85+
7686
* ```ts
7787
function toString(): string
7888
```

0 commit comments

Comments
 (0)