String

This is the String class.

A string is basic datatype which stores an arbitrary sequence of bytes,
typically representing characters. String literals are delimited by
double quotes, like so: "The quick brown fox jumps over the lazy dog".

Methods

length

$string.length

Property. Character length of the string.

uppercase

$string.uppercase

Property. A string based on the original with an uppercase transformation.

lowercase

$string.lowercase

Property. A string based on the original with a lowercase transformation.

split

$string.split()

Returns a list of substrings based on the division of the original
string by the provided separator.

Arguments

optionalseparator: Str | Rgx - Substring separator. The default is the empty string, which results
in a list of individual characters.

optionallimit: Num - Number of substrings to extract.
If specified, the returned list will have at most this number
of strings. The final string in that list may include occurrences
of the separator.

fill

$string.fill()

Returns a string based on the original string with placeholders within
the delimiters << and >> replaced with the provided values.

This method takes named arguments whose values should be strings or
objects capable of string conversion.

.fill() will also respect indentation. If the provided values are
multi-line, they will be indented at the same depth as the placeholder.

For example, "Hi <<name>>!".fill(name: "Steve") returns "Hi Steve!".

Arguments

optionalvalueHash: Hash - If provided, the keys and values in this hash will be used to
fill the placeholders rather than the named argument pairs.