Skip to content

Commit

Permalink
doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
yznts committed Feb 17, 2023
1 parent d8a157b commit e5a976e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ newdata := slice.Filter(data, func(v int) {
})
```

Need to convert a slice of values to something different? Not a big deal. Just give a processing function to "slice.Map".

```go
data := []int{654, 234, 546, 23, 76, 87, 34, 232, 656, 767, 23, 4, 546, 56}
datastr := slice.Map(data, strconv.Itoa) // You'll get []string{...}
```

Let's look at another example. Sometimes you run into situations where the structure takes a pointer to a simple type, like string. It's understandable, sometimes we need to take nil as one of the possible states. But if we will try to create a pointer from an inline value, we get an error.

```go
Expand Down
6 changes: 6 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Let's see what it would look like with our package.
return v > 50
})
Need to convert a slice of values to something different?
Not a big deal. Just give a processing function to "slice.Map".
data := []int{654, 234, 546, 23, 76, 87, 34, 232, 656, 767, 23, 4, 546, 56}
datastr := slice.Map(data, strconv.Itoa) // You'll get []string{...}
Let's look at another example.
Sometimes you run into situations where the structure takes a pointer to a simple type, like string.
It's understandable, sometimes we need to take nil as one of the possible states.
Expand Down

0 comments on commit e5a976e

Please sign in to comment.