Tweaks to other samples to accommodate strings-and-runes

Add a link to the range sample, and remove partial mentions of this
topic in string-functions since it's now covered well in
strings-and-runes
This commit is contained in:
Eli Bendersky
2022-02-05 07:11:37 -08:00
parent b2057ccfd2
commit e604254e38
7 changed files with 14 additions and 69 deletions

View File

@@ -42,6 +42,8 @@ func main() {
// `range` on strings iterates over Unicode code
// points. The first value is the starting byte index
// of the `rune` and the second the `rune` itself.
// See [Strings and Runes](strings-and-runes) for more
// details.
for i, c := range "go" {
fmt.Println(i, c)
}

View File

@@ -1,2 +1,2 @@
c7d9ae9ed081fb4bbf27ef45242fbb39bbae3d4c
pdZOtv4g-7J
c8da490660d234fc420f39d9b8a4aba27f8aba46
kRsyWNmLFLz

View File

@@ -35,17 +35,4 @@ func main() {
p("ToLower: ", s.ToLower("TEST"))
p("ToUpper: ", s.ToUpper("test"))
p()
// Not part of `strings`, but worth mentioning here, are
// the mechanisms for getting the length of a string in
// bytes and getting a byte by index.
p("Len: ", len("hello"))
p("Char:", "hello"[1])
}
// Note that `len` and indexing above work at the byte level.
// Go uses UTF-8 encoded strings, so this is often useful
// as-is. If you're working with potentially multi-byte
// characters you'll want to use encoding-aware operations.
// See [strings, bytes, runes and characters in Go](https://blog.golang.org/strings)
// for more information.

View File

@@ -1,2 +1,2 @@
33b15b8c999ba65564b965b96cbfeadac0d1637d
fZ_FqN5WlSz
2201eba7e3b9339a6e700a4faa9b085c43dd1ed2
pE_KNt12Zv9

View File

@@ -11,6 +11,3 @@ Replace: f0o
Split: [a b c d e]
ToLower: test
ToUpper: TEST
Len: 5
Char: 101