Huh? Isn’t your code calling the exact same method ?

> On Jan 7, 2019, at 12:22 PM, peterGo <go.peter...@gmail.com> wrote:
> 
> Nikolai,
> 
> "What is the easiest way to make a string "LikeThis" --> "likeThis"?"
> 
> Te easiest is not always the best.
> 
> The code should be correct and reasonably efficient. For example,
> 
> func firstToLower(s string) string {
>     if len(s) > 0 {
>         r, size := utf8.DecodeRuneInString(s)
>         if r != utf8.RuneError || size > 1 {
>             lo := unicode.ToLower(r)
>             if lo != r {
>                 s = string(lo) + s[size:]
>             }
>         }
>     }
>     return s
> }
> 
> $ go test tolow_test.go -bench=.
> BenchmarkToLow-4    30000000    41.3 ns/op     8 B/op    1 allocs/op
> BenchmarkLow-4     200000000     6.96 ns/op    0 B/op    0 allocs/op
> $
> 
> Playground: https://play.golang.org/p/z6CLIS7LaHo
> 
> Peter
> 
> On Saturday, November 24, 2012 at 5:51:23 AM UTC-5, Nikolai wrote:
> Hi!
> 
> What is the easiest way to make a string "LikeThis" --> "likeThis"?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com 
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to