Created
December 18, 2022 02:37
-
-
Save xvbnm48/b1ffce2219af8505942034b918f3bfd8 to your computer and use it in GitHub Desktop.
slice for golang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// Membuat slice dengan make | |
a := make([]int, 5) | |
fmt.Println(a) // Output: [0 0 0 0 0] | |
// Membuat slice dengan sintaks []T | |
b := []int{1, 2, 3, 4, 5} | |
fmt.Println(b) // Output: [1 2 3 4 5] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment