Add examples of maps/slices packages

This commit is contained in:
Eli Bendersky
2023-08-22 05:52:14 -07:00
parent 2166e61181
commit 146bd9cce2
8 changed files with 75 additions and 15 deletions

View File

@@ -3,7 +3,10 @@
package main
import "fmt"
import (
"fmt"
"slices"
)
func main() {
@@ -70,6 +73,13 @@ func main() {
t := []string{"g", "h", "i"}
fmt.Println("dcl:", t)
// The `slices` package contains a number of useful
// utility functions for slices.
t2 := []string{"g", "h", "i"}
if slices.Equal(t, t2) {
fmt.Println("t == t2")
}
// Slices can be composed into multi-dimensional data
// structures. The length of the inner slices can
// vary, unlike with multi-dimensional arrays.

View File

@@ -1,2 +1,2 @@
9f1302a9c3cf79e5144c4818ea09465ff8d6da57
553_cYPVlPH
522c14373ae9581dd3001be32530cdf940637646
kiy1StxorBF

View File

@@ -12,6 +12,7 @@ sl1: [c d e]
sl2: [a b c d e]
sl3: [c d e f]
dcl: [g h i]
t == t2
2d: [[0] [1 2] [2 3 4]]
# Check out this [great blog post](https://go.dev/blog/slices-intro)