diff --git a/examples/range/range.go b/examples/range/range.go index 011af67..ec44c3f 100644 --- a/examples/range/range.go +++ b/examples/range/range.go @@ -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) } diff --git a/examples/range/range.hash b/examples/range/range.hash index f6e5a86..f2e2c7b 100644 --- a/examples/range/range.hash +++ b/examples/range/range.hash @@ -1,2 +1,2 @@ -c7d9ae9ed081fb4bbf27ef45242fbb39bbae3d4c -pdZOtv4g-7J +c8da490660d234fc420f39d9b8a4aba27f8aba46 +kRsyWNmLFLz diff --git a/examples/string-functions/string-functions.go b/examples/string-functions/string-functions.go index 676e904..5686f71 100644 --- a/examples/string-functions/string-functions.go +++ b/examples/string-functions/string-functions.go @@ -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. diff --git a/examples/string-functions/string-functions.hash b/examples/string-functions/string-functions.hash index 68fb9a4..5f85212 100644 --- a/examples/string-functions/string-functions.hash +++ b/examples/string-functions/string-functions.hash @@ -1,2 +1,2 @@ -33b15b8c999ba65564b965b96cbfeadac0d1637d -fZ_FqN5WlSz +2201eba7e3b9339a6e700a4faa9b085c43dd1ed2 +pE_KNt12Zv9 diff --git a/examples/string-functions/string-functions.sh b/examples/string-functions/string-functions.sh index b83688d..a38da5e 100644 --- a/examples/string-functions/string-functions.sh +++ b/examples/string-functions/string-functions.sh @@ -11,6 +11,3 @@ Replace: f0o Split: [a b c d e] ToLower: test ToUpper: TEST - -Len: 5 -Char: 101 diff --git a/public/range b/public/range index c151ca2..f1fb5b4 100644 --- a/public/range +++ b/public/range @@ -43,7 +43,7 @@ of the data structures we’ve already learned.
package 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.
rune
and the second the rune
itself.
+See Strings and Runes for more
+details.
package main
strings
package docs.
- p("Contains: ", s.Contains("test", "es")) @@ -115,43 +115,11 @@ package docs. 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
-for more information.
- | + |
$ go run string-functions.go Contains: true @@ -178,17 +146,6 @@ for more information. |
-
- - | -
-
- Len: 5 -Char: 101- |
-