Skip to content

Commit

Permalink
Merge branch 'main' of github.com:gogf/gf-site
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Nov 21, 2024
2 parents cf2e159 + b41ed99 commit 1d9ad45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ func main() {
}
```

### `Reverse` 数组翻转
### `Reverse` 数组反转

```go
package main
Expand All @@ -288,13 +288,13 @@ import (
)

func main() {
array := garray.NewFrom(g.Slice{1, 2, 3, 4, 5, 6, 7, 8, 9})
array := garray.NewFrom(g.Slice{1, 5, 3})

// Reverse makes array with elements in reverse order.
// Reverse makes array with elements reverse.
fmt.Println(array.Reverse().Slice())

// Output:
// [9 8 7 6 5 4 3 2 1]
// [3 5 1]
}
```

Expand Down Expand Up @@ -486,4 +486,4 @@ func main() {

```
{1 john [100,99,98]}
```
```
Original file line number Diff line number Diff line change
Expand Up @@ -1040,22 +1040,22 @@ func ExampleStrArray_Replace() {

## `Reverse`

- 说明:将数组中的所有元素用倒序进行排序
- 说明:将数组中的所有元素反转
- 格式:

```go
Replace(array []string) *StrArray
```

- 示例:建立1个新数组,初始化后执行倒序操作并打印
- 示例:建立1个新数组,初始化后执行反转操作并打印

```go
func ExampleStrArray_Reverse() {
s := garray.NewStrArrayFrom(g.SliceStr{"a", "b", "c", "d", "e", "f", "g", "h"})
s := garray.NewStrArrayFrom(g.SliceStr{"a", "m", "c"})
fmt.Println(s.Reverse())

// Output:
// ["h","g","f","e","d","c","b","a"]
// ["c","m","a"]
}
```

Expand Down

0 comments on commit 1d9ad45

Please sign in to comment.