Created
June 11, 2024 19:23
-
-
Save ppcamp/c664e2b2dc64fe8c40c9ab52b087a602 to your computer and use it in GitHub Desktop.
Simple examples non intrisic 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
// You can edit this code! | |
// Click here and start typing. | |
package main | |
import "fmt" | |
func main() { | |
a := []string{"foo", "bar", "baz", "zas"} | |
fmt.Println(len(a), a) // 4 [foo bar baz zas] | |
n := len(a) - 1 | |
last, a := a[n], a[:n] | |
fmt.Println(last, a) // zas [foo bar baz] | |
n = len(a) - 1 | |
a, last = a[:n], a[n] | |
fmt.Println(last, a) // baz [foo bar] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment