exercices of section 13
This commit is contained in:
21
Section13/4.go
Normal file
21
Section13/4.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s1 := "Go is cool!"
|
||||
|
||||
x := s1[0]
|
||||
fmt.Println(x)
|
||||
|
||||
// ERROR -> cannot assign to s1[0]
|
||||
// s1[0] = 'x'
|
||||
|
||||
// printing the number of runes in the string
|
||||
// fmt.Println(len(s1))
|
||||
fmt.Println(utf8.RuneCountInString(s1))
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user