Created
April 12, 2017 06:14
-
-
Save oyakata/f6ad7b174544a265db1f8108f7f2182c to your computer and use it in GitHub Desktop.
Goはスライス型で宣言した変数にnilを代入しても空のスライスのまま
This file contains hidden or 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() { | |
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