Last active
November 30, 2016 23:24
-
-
Save tevjef/c5e1abe271742910f3dc5289f9aeef38 to your computer and use it in GitHub Desktop.
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() { | |
structArr() | |
structLiteral() | |
} | |
type myStruct struct { str string } | |
func structArr() { | |
for i := []myStruct{"a", "b", "c", "d"}; len(i) > 0; i = i[:len(i)-1] { | |
fmt.Println(i) | |
} | |
} | |
func structLiteral() { | |
// fails to compile. according to the spec composite literals are not allowed in init block | |
for i := myStruct{"abcd"}; len(i) > 0; i = i[:len(i)-1] { | |
fmt.Println(i) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wtf golang/go#6386