...

/

Strings, Arrays and Slices

Strings, Arrays and Slices

This lesson is a flashback to the standard operations and their syntaxes defined on strings, arrays, and slices.

📝 Useful code snippets for strings

Changing a character in a string

Strings are immutable, so in fact a new string is created here.

str := "hello"
c := []rune(str)
c[0] = 'c'
s2 := string(c) // s2 == "cello"

Taking a part (substring) of a string

substr := str[n:m]

Looping over a string with for or for-range

 ...