Skip to main content

string

Base class: Object

Represents a sequence of characters.

Constructors​

string() -> string​

Creates a default-constructed instance of string.

string(const Slice value) -> string​

Returns a standardized string representation for a Slice.

Parameters​

  • value: The value to convert to string.

string(const BenchmarkResult value) -> string​

Returns a standardized string representation for a BenchmarkResult.

Parameters​

  • value: The value to convert to string.

string(const Timer value) -> string​

Returns a standardized string representation for a Timer.

Parameters​

  • value: The value to convert to string.

string(const TimerDuration duration) -> string​

Converts the duration to a human-readable string with appropriate units.

Parameters​

  • duration: The duration to convert to string.

string(const string other) -> string​

Creates a copy of an existing string object.

Parameters​

  • other: The string object to copy.

string(const Number number) -> string​

Converts a number to its string representation.

Parameters​

  • number: The number to convert to string.

string(bool b) -> string​

Converts a boolean value to its string representation.

Parameters​

  • b: The boolean value to convert.

Returns​

The string representation of the boolean value ('true' or 'false').

string(const complex value) -> string​

Converts a value to its string representation.

Parameters​

  • value: The value to convert to a string.

Symbols​

NameDescription
!=Performs inequality comparison operation.
+Performs addition operation.
+=Performs addition assignment operation.
<Performs less than comparison operation.
<=Performs less than or equal comparison operation.
=Assigns the value of the right-hand side to the left-hand side.
==Performs equality comparison operation.
>Performs greater than comparison operation.
>=Performs greater than or equal comparison operation.
[]Accesses an element at the specified index.

Members​

NameDescription
backReturns the last element in the container. Throws an exception if the container is empty.
capacityReturns the number of elements that the container has currently allocated space for.
capitalizeReturn a capitalized version of the string.
clearClears all elements from the container.
containsChecks if a string contains the given string.
countReturns the number of occurrences of the specified value in the container.
emptyChecks if the container is empty.
ends_withChecks if a string ends with the given string.
eraseRemoves the first occurrence of the specified value from the container.
erase_atErases the element at the specified position in the container.
extendExtends the string by appending all elements from another string.
findFinds the first occurrence of a substring starting from the given position.
find_first_not_ofFinds the first character not contained in a character list.
find_first_ofFinds the first character contained in a character list.
find_last_not_ofFinds the last character not contained in a character list.
find_last_ofFinds the last character contained in a character list.
frontReturns the first character in the string. Throws an exception if the string is empty.
indexReturns the index of the first occurrence of the specified value in the container.
insert_atInserts an element at the specified position in the container.
is_alphaChecks if the string consists only of alphabetic characters.
is_digitChecks if the string consists only of digits.
is_sortedChecks if the container is sorted in increasing order (comparison operator<).
ltrimRemoves whitespace from the beginning of a string.
pop_backRemoves the last element from the container. Throws an exception if the container is empty.
push_backAppends an element to the end of the container.
replaceReplaces all occurrences of a string within the given string.
replacedReplaces all occurrences of a string within the given string.
replicateReplicates the container n times.
replicatedCreates a new container by replicating the original container n times.
reserveReserves storage for at least the specified number of elements.
resizeResizes the container to contain the specified number of elements.
reverseReverses the order of elements in the container. Returns the container itself.
reversedReturns a reversed copy of the the container.
rfindFinds the last occurrence of a substring at or before the given position.
rtrimRemoves whitespace from the end of a string.
sizeReturns the number of elements in the container.
sortSorts the container in place using the provided comparison function and returns the sorted container.
sortedReturns a sorted copy of the container.
splitSplits the given string into a list of strings.
starts_withChecks if a string starts with the given string.
substrReturns a substring starting at the specified position with the specified length.
to_lowercaseConvert the given string to lowercase letters.
to_uppercaseConvert the given string to uppercase letters.
trimRemoves whitespace from both ends of a string.
trim_endTrims the end of the given string.
trim_startTrims the beginning of the given string.