Skip to content

Commit 5e4c1ad

Browse files
authored
Merge pull request mouredev#2653 from kodenook/develop
Reto #3 - go
2 parents 58ee6f8 + fc59325 commit 5e4c1ad

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"sort"
6+
)
7+
8+
func main() {
9+
/* Array */
10+
11+
var arr1 = [5]int{1, 2, 3, 4, 5}
12+
13+
// edit
14+
15+
arr1[0] = 6
16+
fmt.Println(arr1)
17+
18+
/* Slice */
19+
20+
var slice []int = arr1[1:4]
21+
22+
// add
23+
24+
slice = append(slice, 5)
25+
fmt.Println(slice)
26+
27+
// edit
28+
29+
slice[0] = 7
30+
fmt.Println(slice)
31+
32+
// delete
33+
34+
slice = append(slice[:1], slice[2:]...)
35+
fmt.Println(slice)
36+
37+
// sort
38+
39+
sort.Ints(slice)
40+
fmt.Println(slice)
41+
42+
/* Map */
43+
44+
var cars = map[int]string{1: "ford", 2: "toyota", 3: "chevrolet"}
45+
46+
// add/edit
47+
48+
cars[4] = "renault"
49+
fmt.Println(cars)
50+
51+
// delete
52+
53+
delete(cars, 1)
54+
fmt.Println(cars)
55+
}

0 commit comments

Comments
 (0)