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:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
c7d9ae9ed081fb4bbf27ef45242fbb39bbae3d4c
|
||||
pdZOtv4g-7J
|
||||
c8da490660d234fc420f39d9b8a4aba27f8aba46
|
||||
kRsyWNmLFLz
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
33b15b8c999ba65564b965b96cbfeadac0d1637d
|
||||
fZ_FqN5WlSz
|
||||
2201eba7e3b9339a6e700a4faa9b085c43dd1ed2
|
||||
pE_KNt12Zv9
|
||||
|
||||
@@ -11,6 +11,3 @@ Replace: f0o
|
||||
Split: [a b c d e]
|
||||
ToLower: test
|
||||
ToUpper: TEST
|
||||
|
||||
Len: 5
|
||||
Char: 101
|
||||
|
||||
Reference in New Issue
Block a user