A string is a sequence of bytes that cannot be changed. Strings can contain any data and are generally used to save text.

We generally use double quotes “” to define a string, but note that there are specific characters that have a specific meaning, which we call escaped characters, and these escaped characters contain:

  \n:line break
  \u or \U:Unicode

println("hello" + "\t" + "world") // hello world println(len("helloword")) // 9 str := "helloword" println(str) // helloword println(len(str)) // 9 str1 := "hello" + "word" println(str1) // helloword str2 := "my name is \t" str3 := "zs" println(str2 + str3) // my name is zs const str4 = `First line Second line Third line ` println(str4)

If we want to know the length of the strings taken up by bytes, we can use Go+’s built-in functions to calculate it:

If we were to define a string, the grammar would be as follows:

We can stitch two strings together by +, appending the later string to the later of the earlier string.

If we want to define a multi-line string, Go+ supports that too. Using the traditional “” is not possible across lines, we can use backquotes if we want to define a multi-line string: `

The code between the backquotes is not recognized by the editor, but only as part of the string.

Next example: Rational Numbers