1.3 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.3 KiB
		
	
	
	
	
	
	
	
Strings, Runes and Bytes Quiz
Which byte slice below equals to the "keeper" string?
// Here are the corresponding code points for the runes of "keeper":
// k => 107
// e => 101
// p => 112
// r => 114
- []byte{107, 101, 101, 112, 101, 114} CORRECT
 - []byte{112, 101, 101, 112, 114, 101}
 - []byte{114, 101, 112, 101, 101, 112}
 - []byte{112, 101, 101, 114, 107, 101}
 
What does this code print?
// Code points:
// g => 103
// o => 111
fmt.Println(string(103), string(111))
- 103 111
 - g o CORRECT
 - n o
 - "103 111"
 
What does this code print?
const word = "gökyüzü"
bword := []byte(word)
// ö => 2 bytes
// ü => 2 bytes
fmt.Println(utf8.RuneCount(bword), len(word), len(string(word[1])))
- 7 10 2 CORRECT
 - 10 7 1
 - 10 7 2
 - 7 7 1
 
Which one below is true?
- for range loops over the bytes of a string
 - for range loops over the runes of a string CORRECT
 
For a utf-8 encoded string value, which one below is true?
- runes always start and end in the same indexes
 - runes may start and end in different indexes CORRECT
 - bytes may start and end in different indexes
 
Why can't you change the bytes of a string value?
- Strings values are immutable byte slices
 - Strings are used a lot so they are being shared behind the scenes
 - All of above CORRECT