Strings
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 \r:Enter \t:Tab \u or \U:Unicode \:Backslash
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