I am reading the doc about Assignability in Golang Specification 
<https://golang.org/ref/spec#Assignability> . It says:

A value x is *assignable* to a variable 
<https://golang.org/ref/spec#Variables> 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 
   <https://golang.org/ref/spec#Types> and at least one of V or T is not a 
   defined <https://golang.org/ref/spec#Type_definitions> type.
   - ...


type str string

func main() {
string1 := "string"
var str1 str = "str1"
str1 = string1 // cannot use string1 (type string) as type str in assignment
}


string1's type string and str have identical underlying type (string) and 
string is not a defined type. 

So why cannot i assign string1 to str1?

-- 
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+unsubscr...@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.

Reply via email to