A value x
is assignable to a variable of type T
("x
is assignable to T
") if one of the following conditions applies:
x
's type V
and T
have identical underlying types and at least one of V
or T
is not a defined type.type str string
func main() { string1 := "string" var str1 str = "str1" str1 = string1 // cannot use string1 (type string) as type str in assignment}
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/8fedba03-5aa1-4227-80c5-686a87a45cdd%40googlegroups.com.
type str string
var s str = "sdwf"
// boolean literaltype boolean boolvar b boolean = true
// integer literaltype integer intvar i integer = 1
// slice literaltype strarr []stringvar strings []string = []string{"sfw"}var strs strarr = strings
// pointer literaltype stringptr *stringvar string1 string = "11"var ptr stringptr = &string1
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/55a9008d-a7f0-4de1-a420-57f6bbb19774%40googlegroups.com.