Skip to content

Instantly share code, notes, and snippets.

@ppcamp
Created June 11, 2024 19:23
Show Gist options
  • Save ppcamp/c664e2b2dc64fe8c40c9ab52b087a602 to your computer and use it in GitHub Desktop.
Save ppcamp/c664e2b2dc64fe8c40c9ab52b087a602 to your computer and use it in GitHub Desktop.
Simple examples non intrisic golang
// 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