String
- typeString
The string type
A
Stringliteral 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
- functionrepeat(self: String, n: u32) String
Repeat a string
ntimes 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