package mantra.lang
String
CLASS
public final class
Immutable heap-allocated UTF-8 string with length caching, slicing, and string interpolation support.
🏗️ Constructor Summary
Constructor Signature
def __init__(self, value: String)
⚙️ Method Summary
| Modifier & Return Type | Method Signature | Description |
|---|---|---|
Int |
len() |
Returns the number of Unicode characters in the string. |
Bool |
contains(substring: String) |
Checks if the given substring is contained within this string. |
String |
to_upper() |
Returns a new uppercase copy of the string. |
String |
to_lower() |
Returns a new lowercase copy of the string. |
🔍 Detailed Method Specifications
pub def len() -> Int
Returns the number of Unicode characters in the string.
pub def contains(substring: String) -> Bool
Checks if the given substring is contained within this string.
pub def to_upper() -> String
Returns a new uppercase copy of the string.
pub def to_lower() -> String
Returns a new lowercase copy of the string.
💡 Example Usage
string_example.mantra
let title = "Mantra Language"
print("Length: " + str(title.len()))
assert(title.contains("Mantra"))