Skip to content

Instantly share code, notes, and snippets.

@oyakata
Created April 12, 2017 06:14
Show Gist options
  • Save oyakata/f6ad7b174544a265db1f8108f7f2182c to your computer and use it in GitHub Desktop.
Save oyakata/f6ad7b174544a265db1f8108f7f2182c to your computer and use it in GitHub Desktop.
Goはスライス型で宣言した変数にnilを代入しても空のスライスのまま
package main
import (
"fmt"
)
func main() {
var xs []string
xs = nil
fmt.Println(xs, len(xs))
for i, x := range xs {
fmt.Println(i, x)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment