What is the output?
for i := range "hé!" {
fmt.Print(i)
}
- 012
- 013
- 0123
- 123
Ranging over a string yields the byte offset of each rune. é takes two bytes in UTF-8, so the offsets are 0, 1 and 3.
Play Problem Solving ▸
for i := range "hé!" {
fmt.Print(i)
}