diff options
| author | Andrew Todd <andrew.todd@wework.com> | 2019-07-27 16:20:49 -0700 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2019-07-30 02:52:57 +0000 |
| commit | fbb819ebc443518e9caea3c1b0d0f9e0efec2262 (patch) | |
| tree | d153c5c6138aff5431f1bdd82b546604a53fda33 /src/strings/example_test.go | |
| parent | 01d137262a713b308c4308ed5b26636895e68d89 (diff) | |
| download | go-fbb819ebc443518e9caea3c1b0d0f9e0efec2262.tar.xz | |
strings: clarify usage of Title and ToTitle
This is intended to help clear up confusion around the usage of the
Title and ToTitle functions. It includes a link to define title case
to distinguish it from upper case. It also includes an additional
example for the ToTitle function to showcase the difference in behavior
between it and the Title function.
Fixes #33302
Change-Id: I44e62962fb04d0d22966a39eda3a2d16de7a2291
Reviewed-on: https://go-review.googlesource.com/c/go/+/187825
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/strings/example_test.go')
| -rw-r--r-- | src/strings/example_test.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/strings/example_test.go b/src/strings/example_test.go index 4f3a1ce8c6..375f9cac65 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -247,14 +247,23 @@ func ExampleSplitAfterN() { } func ExampleTitle() { + // Compare this example to the ToTitle example. fmt.Println(strings.Title("her royal highness")) - // Output: Her Royal Highness + fmt.Println(strings.Title("loud noises")) + fmt.Println(strings.Title("хлеб")) + // Output: + // Her Royal Highness + // Loud Noises + // Хлеб } func ExampleToTitle() { + // Compare this example to the Title example. + fmt.Println(strings.ToTitle("her royal highness")) fmt.Println(strings.ToTitle("loud noises")) fmt.Println(strings.ToTitle("хлеб")) // Output: + // HER ROYAL HIGHNESS // LOUD NOISES // ХЛЕБ } |
