Created
May 3, 2018 20:17
-
-
Save jcamilom/3f404350c63760debcaed1b542469b4e to your computer and use it in GitHub Desktop.
[Mutate string] How to change individual chars of a string. From https://golangbot.com/strings/ #go #golang #strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func mutate(s []rune) string { | |
s[0] = 'a' | |
return string(s) | |
} | |
func main() { | |
h := "hello" | |
fmt.Println(mutate([]rune(h))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment