String

typeString

The string type

A String literal is created by putting some text between double quotes.

let x = "Hello!";

See the language reference for more information. Roto supports string formatting when a string literal is prefixed with an f.

functionappend(self: String, other: String) String

Append a string to another, creating a new string

"hello".append(" ").append("world") # -> "hello world"
functioncontains(self: String, needle: String) bool

Check whether a string contains another string

"haystack".contains("hay")  # -> true
"haystack".contains("corn") # -> false
functionends_with(self: String, suffix: String) bool

Check whether a string ends with a given suffix

"haystack".ends_with("stack") # -> true
"haystack".ends_with("black") # -> false
functioneq(self: String, other: String) bool

Check for string equality

functionrepeat(self: String, n: u32) String

Repeat a string n times and join them

"ha".repeat(6) # -> "hahahahahaha"
functionstarts_with(self: String, prefix: String) bool

Check whether a string starts with a given prefix

"haystack".starts_with("hay")   # -> true
"haystack".starts_with("trees") # -> false
functionto_lowercase(self: String) String

Create a new string with all characters converted to lowercase

"LOUD".to_lowercase() # -> "loud"
functionto_string(self: String) String

Convert this value into a String

functionto_uppercase(self: String) String

Create a new string with all characters converted to uppercase

"quiet".to_uppercase() # -> "QUIET"