String
For now niva using java.String, so everything about Java strings also applies to niva strings.
For example, immutability and deduplication(small strings are stored once if they are the same, so 10k of "Cat"s strings will take up space as one)
Interpolation of variables is supported(but not for expressions):
Every niva object has a string representation:
Message echo and string interpolation apply the toString method automatically.
unary
Length of this String
Returns a string with characters in reversed order
Returns a string having leading and trailing whitespace removed
Detects a common minimal indent of all the input lines, removes it from every line
true if this char sequence is empty or consists solely of whitespace characters
Only the "" is true
True if its only digits and characters like "abc123"
Opposite to isBlank
Opposite to isEmpty
Returns the first character or panic
Returns the last character or panic
binary
Concatenate 2 Strings
keyword
"Tom the cat" replace: "cat" with: "mouse"
"abc" forEach: [char -> char echo] // a b c
"abc" forEachIndexed: [index, char -> char echo] // a b c
"abc" filter: [it != 'c'] // "ab"
"abc" startsWith: "ab" // true
see startWith:
Returns a substring of this string that starts at the specified startIndex and continues to the end of the string
Returns a string containing characters of the original string at the specified range
Returns a substring after the first occurrence of delimiter
see substringAfter:
see substring:
Returns the character of this string at the specified index or panic
Returns a string with the first n characters removed "abc" drop: 5 // empty ""
Returns a string with the last n characters removed