Strings
Strings in Budgie are denoted with double apostrophes ("
). Do not use single apostrophes or back-ticks.
Some languages, such as C#, use single apostrophes to denote single characters and not strings.
Concatenation
The concatenate
command appends two or more strings together.
In C#:
"abc" + def + "ghi"
In Python:
"abc" + def + "ghi"
Characters
Some languages, such as JavaScript and Ruby, do not recognize a difference between a one-length string, or char
, and an arbitrary-length string
. Less high-level languages, such as C# and Java, consider them to be a char
.
In C#:
char a = 'a';
In Python:
a = "a"
Indexing
Individual characters in a string may be indexed with the string index
command. It takes in a string and a character index int, and returns a char
.
In C#:
In Python:
Formatting
The string format
command allows inserting primitives into a format string. It takes in a single format string, then any number of input name & type pairs. Format strings are string literals with any number of bracket-surrounded numbers inside, with the format {#}
.
In C#:
In Python:
Some languages, such as C# and Python above, use string formatting with numeric insertion points into the template string. Some, such as JavaScript, boil down to concatenating them together. As a result, it is not allowed to use the same {#}
number multiple times in the format string.
Searching
The string index of
command can be used to determine whether a substring exists within a string. It returns the index of the substring if found, or the equivalent of the string index not found
command if not found. It may also take in an optional third parameter as an integer position within the string to start searching at, if not 0
.
In C#:
In Python:
Last updated