A rune is just an alias for int32. So when you are printing r, you are printing a int32 number.
s is a string. So when you print it, you get the expected output ("a"). Em seg, 22 de ago de 2016 às 12:51, JC <mr.jamie.caldw...@gmail.com> escreveu: > Dear gophers, > > I'd appreciate some help. > > Given: > > func main() { > r := 'a' > s := "a" > fmt.Println(r) > fmt.Println(s) > } > > My very possibly incorrect understanding is that the rune r holds a > Unicode code-point encoded with UTF-8 and stored as integer value, in this > case 97, as type int32. s is of type string, and contains a code-point > encoded by UTF-8, but which will be stored in a slice of type byte (which > will use just one uint8 in this case). Assuming that is all correct, > then my questions are: > > 1. Will the rune / any rune always use 32 bits? > 2. Why does printing r output the integer value, but printing s yield the > code-point itself? > > Cheers for your help. > JC. > > > -- > 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. > For more options, visit https://groups.google.com/d/optout. > -- 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. For more options, visit https://groups.google.com/d/optout.