Skip to content

Commit

Permalink
Added example with indices in the initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
adriancuadrado committed Apr 14, 2024
1 parent bbf6b80 commit 9c88909
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/arrays/arrays.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func main() {
b = [...]int{1, 2, 3, 4, 5}
fmt.Println("dcl:", b)

// If you specify the index with `:`, the elements in
// between will be zeroed.
b := [...]int{100, 3: 400, 500}
fmt.Println(b)

// Array types are one-dimensional, but you can
// compose types to build multi-dimensional data
// structures.
Expand Down
1 change: 1 addition & 0 deletions examples/arrays/arrays.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ get: 100
len: 5
dcl: [1 2 3 4 5]
dcl: [1 2 3 4 5]
idx: [100 0 0 400 500]
2d: [[0 1 2] [1 2 3]]

0 comments on commit 9c88909

Please sign in to comment.