Go Type System and Type Conversion
A Failure of Assignment
Recently, my friend asked me a question, why inthe following go code, b
cannot be assigned to f
? With knowledges about AST, I got intrigue on it than ever before.
The failure is caused by Bar
and Foo
are not same type, hence, they cannot be assigned to each other. However, assign a string to Bar
or Foo
directly is valid.
This blog talks why the conversion fails and will introduce the type, type definition, properities of types with some examples.