Skip to content

String Method Reference

Returns a string of both values concatenated together.

var string1 = "Hello ";
var string2 = "World!";
var combined_string = string1.concat(string2) // "Hello World!"

other: String - The other string to combine with.

String - The combined string.

Returns an array of strings split at the provided delimeter.

var string = "Hello World!";
var arr1 = string.split(); // ["H", "e", "l", "l", o", " ", "W", "o", "r", "l", "d", "!"]
var arr2 = string.split(" "); // ["Hello", "World!"];

delimter: String? optional - The delimeter to use when splitting the arrays into strings. If none is provided, "" is used.

String - An array of strings split by the delimeter.

Returns a string with all characters lowercased.

var string = "Hello World!";
var lowercase_string = string.to_lowercase(); // "hello world!"

None

String - The lowercased string.

Returns a Result with either the converted value wrapped in Ok, or an Err.

var number_as_string = "1234";
var number = number_as_string.to_number().unwrap(); // 1234
var not_a_number = "x";
assert_throws(() -> not_a_number.to_number().unwrap()); // true

None

Result - The result of the conversion. If successful, the number will be wrapped in Ok, otherwise an Err will be returned.

Returns a string with all characters uppercased.

var string = "Hello World!";
var uppercase_string = string.to_uppercase(); // "HELLO WORLD!"

None

String - The uppercased string.