Core runtime library providing primitive types (Bool, Byte, Char, Int, Float, String), base collections, and system utilities. Every Objeck program links against this bundle automatically via lang.obl.
String
Resizeable Unicode character string
Example
# build and print string
cities_str := "\t\tNapa,";
cities_str += "Fremont,";
cities_str += "Alameda,";
cities_str += "Berkeley,";
cities_str += "Fremont,";
cities_str += "San Carlos,";
cities_str += "Milpitas, ";
cities_str->PrintLine();
# show the string size
cities_str->Size()->PrintLine();
# trim string
cities_str := cities_str->Trim();
cities_str->Size()->PrintLine();
# replace city
cities_str := cities_str->Replace("San Carlos", "Oakland");
cities_str->PrintLine();
# create a substring
start := cities_str->Find("Berkeley");
if(<>start->IsNeg()) {
end := cities_str->Find(start, ',');
if(<>end->IsNeg()) {
city := cities_str->SubString(start, end - start);
"They city found was {$city}"->PrintLine();
}
};
# remove ending comma
cities_str->Pop();
# split string and print values
cities := cities_str->Split(',');
cities->Size()->PrintLine();
# iterate over cities
each(city := cities) {
city->PrintLine();
};
# iterate over cities with an index
each(i : cities) {
city := cities[i];
"{$i}: |{$city}|"->PrintLine();
};Operations
- New
- Append
- Capacity
- Clear
- Clone
- Compare
- CompareIgnoreCase
- Compress
- Contains
- ContainsIgnoreCase
- Copy
- Count
- Delete
- EndsWith
- EndsWithIgnoreCase
- Equals
- EqualsIgnoreCase
- Error
- ErrorLine
- Find
- FindAll
- FindLast
- First
- Format
- Get
- Has
- HashID
- Insert
- IsAlpha
- IsAlphaNumeric
- IsBlank
- IsEmpty
- IsFloat
- IsInt
- IsNumeric
- Join
- Justify
- Last
- Lines
- Pad
- PadTo
- Pop
- PrintLine
- Remove
- RemoveAll
- Repeat
- Replace
- ReplaceAll
- Reverse
- Set
- SetFloatFormat
- SetFloatPrecision
- SetIntFormat
- Size
- Split
- StartsWith
- StartsWithIgnoreCase
- SubString
- ToBool
- ToByteArray
- ToCharArray
- ToFloat
- ToInt
- ToLower
- ToString
- ToUpper
- Trim
- TrimBack
- TrimChars
- TrimFront
- Truncate
Append #
Appends a boolean value
method : public : Append(flag:Bool) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| flag | Bool | boolean value |
Append #
Appends a integer value
method : public : Append(i:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| i | Int | integer value |
Append #
Appends a float value
method : public : Append(f:Float) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| f | Float | float value |
Append #
Appends a string
method : public : Append(str:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| str | String | string object |
Example
s := "Hello";
s->Append(", World");
s->PrintLine(); # Hello, WorldAppend #
Appends a character array
method : public : Append(array:Char[]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| array | Char | character array |
Append # native
Appends a portion of character array
method : public : native : Append(array:Char[], offset:Int, length:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| array | Char | array to be copied |
| offset | Int | offset array index offset |
| length | Int | number of characters to copy |
Append # native
Appends a character array
method : public : native : Append(array:Byte[]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| array | Byte | array to be copied |
Append # native
Appends a portion of byte array
method : public : native : Append(array:Byte[], offset:Int, length:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| array | Byte | array to be copied |
| offset | Int | offset array index offset |
| length | Int | number of bytes to copy |
Append #
Appends a character
method : public : Append(c:Char) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| c | Char | character to append |
Append #
Appends a byte
method : public : Append(c:Byte) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| c | Byte | byte to append |
Capacity #
Gets the current string's storage capacity. That is the number of characters the string will hold before it is resized for growth.
method : public : Capacity() ~ IntReturn
| Type | Description |
|---|---|
| Int | string capacity |
Clone #
Clones the object instance
method : public : Clone() ~ System.StringReturn
| Type | Description |
|---|---|
| String | cloned the object instance |
Compare #
Compares two objects
method : public : Compare(rhs:System.Compare) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| rhs | Compare | compare object |
Return
| Type | Description |
|---|---|
| Int | 0 if equal, -1 if right-hand side i greater, 1 if left-hand side is greater |
CompareIgnoreCase #
Compares two strings, ignoring case
method : public : CompareIgnoreCase(rhs:String) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| rhs | String | string to compare |
Return
| Type | Description |
|---|---|
| Int | 0 if equal, -1 if right-hand side is greater, 1 if left-hand side is greater |
Contains #
Checks if string contains a substring
method : public : Contains(find:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
Return
| Type | Description |
|---|---|
| Bool | true if found, false otherwise |
Example
if("Hello World"->Contains("World")) {
"Found"->PrintLine();
};ContainsIgnoreCase #
Checks if string contains a substring, ignoring case
method : public : ContainsIgnoreCase(find:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
Return
| Type | Description |
|---|---|
| Bool | true if found, false otherwise |
Copy #
Creates a new instance of the string
method : public : Copy() ~ StringReturn
| Type | Description |
|---|---|
| String | new string instance |
Count #
Counts the occurrence of a character
method : public : Count(char:Char) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Int | count of occurrences or -1 if not found |
Count # native
Counts the occurrence of a character
method : public : native : Count(offset:Int, char:Char) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | search offset |
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Int | count of occurrences or -1 if not found |
Count #
Counts occurrences of a substring
method : public : Count(find:String) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to count |
Return
| Type | Description |
|---|---|
| Int | number of occurrences found |
Delete #
Deletes the character at the given index
method : public : Delete(offset:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | offset index |
Return
| Type | Description |
|---|---|
| Bool | true if deleted, false otherwise |
Delete #
Deletes the characters at the given range
method : public : Delete(offset:Int, length:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | offset index |
| length | Int | length |
Return
| Type | Description |
|---|---|
| Bool | true if deleted, false otherwise |
EndsWith #
Checks if the string ends with the given character
method : public : EndsWith(char:Char) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to compare |
Return
| Type | Description |
|---|---|
| Bool | true if ends with character, false otherwise |
Example
if("report.pdf"->EndsWith('f')) {
"Ends with f"->PrintLine();
};EndsWith # native
Checks if the string ends with the given string
method : public : native : EndsWith(string:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| string | String | string to check for |
Return
| Type | Description |
|---|---|
| Bool | true if ends with string, false otherwise |
Example
file := "report.pdf";
if(file->EndsWith(".pdf")) {
"PDF file"->PrintLine();
};EndsWithIgnoreCase #
Checks if the string ends with the given string, ignoring case
method : public : EndsWithIgnoreCase(string:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| string | String | string to check for |
Return
| Type | Description |
|---|---|
| Bool | true if ends with string, false otherwise |
Equals # native
Compares two strings
method : public : native : Equals(rhs:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| rhs | String | string to compare |
Return
| Type | Description |
|---|---|
| Bool | true if equal, false otherwise |
Example
if("hello"->Equals("hello")) {
"Match"->PrintLine();
};Equals #
Compares a string to an array of values
method : public : Equals(rhs:String[]) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| rhs | String | array of values to compare |
Return
| Type | Description |
|---|---|
| Bool | true if at least one match, false otherwise |
EqualsIgnoreCase # native
Compares two strings, ignoring the case
method : public : native : EqualsIgnoreCase(rhs:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| rhs | String | string to compare |
Return
| Type | Description |
|---|---|
| Bool | true if equal, false otherwise |
EqualsIgnoreCase #
Compares a string to an array of values, ignoring case
method : public : EqualsIgnoreCase(rhs:String[]) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| rhs | String | array of values to compare |
Return
| Type | Description |
|---|---|
| Bool | true if at least one match, false otherwise |
Find #
Searches for the first occurrence of a character
method : public : Find(char:Char) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Int | index of first occurrence, -1 otherwise |
Example
pos := "Hello"->Find('l');
pos->PrintLine(); # 2Find # native
Searches for the first occurrence of a character
method : public : native : Find(offset:Int, char:Char) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | search offset |
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Int | index of first occurrence, -1 otherwise |
Find #
Searches for the first occurrence of a string
method : public : Find(find:String) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
Return
| Type | Description |
|---|---|
| Int | index of first occurrence, -1 otherwise |
Example
pos := "Hello World"->Find("World");
"Found at: {$pos}"->PrintLine(); # Found at: 6Find # native
Searches for the first occurrence of a string
method : public : native : Find(offset:Int, find:String) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | search index offset |
| find | String | string to search for |
Return
| Type | Description |
|---|---|
| Int | index of first occurrence, -1 otherwise |
FindAll #
Searches for all occurrences of a string
method : public : FindAll(find:String) ~ Int[]Parameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
Return
| Type | Description |
|---|---|
| Int | an array of indexes |
FindLast #
Searches for the last occurrence of a character
method : public : FindLast(char:Char) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Int | index of last occurrence, -1 otherwise |
FindLast # native
Searches for the last occurrence of a character
method : public : native : FindLast(offset:Int, char:Char) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | search offset |
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Int | index of last occurrence, -1 otherwise |
FindLast #
Searches for the last occurrence of a string
method : public : FindLast(str:String) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| str | String | string to search for |
Return
| Type | Description |
|---|---|
| Int | index of last occurrence, -1 otherwise |
First #
Returns the first character
method : public : First() ~ CharReturn
| Type | Description |
|---|---|
| Char | first character |
Format # function
Formats a string by substituting positional placeholders {0}, {1}, ... with the string value of the matching argument. Use {{ and }} for literal braces. Arguments are stringified via their 'ToString' (Stringify).
function : Format(fmt:String, args:System.Base[]) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| fmt | String | format string with {n} placeholders |
| args | Base | substitution arguments |
Return
| Type | Description |
|---|---|
| String | formatted string |
Example
String->Format("{0} = {1}", "x", 42)->PrintLine(); # x = 42Format # function
Formats a string with a single positional argument. See Format(String, System.Base[]).
function : Format() ~ StringParameters
| Name | Type | Description |
|---|---|---|
Format # function
Formats a string with two positional arguments. See Format(String, System.Base[]).
function : Format() ~ StringParameters
| Name | Type | Description |
|---|---|---|
Format # function
Formats a string with three positional arguments. See Format(String, System.Base[]).
function : Format() ~ StringParameters
| Name | Type | Description |
|---|---|---|
Format # function
Formats a string with four positional arguments. See Format(String, System.Base[]).
function : Format() ~ StringParameters
| Name | Type | Description |
|---|---|---|
Get # native
Returns character at the given index
method : public : native : Get(index:Int) ~ CharParameters
| Name | Type | Description |
|---|---|---|
| index | Int | index offset |
Return
| Type | Description |
|---|---|
| Char | character at index |
Example
ch := "Hello"->Get(1);
ch->PrintLine(); # eHas #
Searches for the first occurrence of a character
method : public : Has(char:Char) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Bool | true of found, false otherwise |
Has #
Searches for the first occurrence of a character
method : public : Has(offset:Int, char:Char) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | search offset |
| char | Char | character to search for |
Return
| Type | Description |
|---|---|
| Bool | true of found, false otherwise |
Has #
Searches for the first occurrence of a character
method : public : Has(str:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| str | String | string to search for |
Return
| Type | Description |
|---|---|
| Bool | true of found, false otherwise |
Has #
Searches for the first occurrence of a character
method : public : Has(offset:Int, str:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | search offset |
| str | String | string to search for |
Return
| Type | Description |
|---|---|
| Bool | true of found, false otherwise |
HashID #
Returns a unique hash ID for a given string sequence
method : public : HashID() ~ IntReturn
| Type | Description |
|---|---|
| Int | hash ID |
Insert #
Insert inserts a character
method : public : Insert(index:Int, char:Char) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| index | Int | insert offset |
| char | Char | character to insert |
Return
| Type | Description |
|---|---|
| Bool | true if inserted, false otherwise |
Insert #
Insert inserts a string
method : public : Insert(index:Int, string:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| index | Int | insert offset |
| string | String | string to insert |
Return
| Type | Description |
|---|---|
| Bool | true if inserted, false otherwise |
Insert #
Insert inserts a string
method : public : Insert(index:Int, buffer:Char[]) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| index | Int | insert offset |
| buffer | Char | buffer to insert |
Return
| Type | Description |
|---|---|
| Bool | true if inserted, false otherwise |
IsAlpha #
Checks if string contains only alphabetic characters (a-z, A-Z)
method : public : IsAlpha() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if all characters are alphabetic, false otherwise |
IsAlphaNumeric #
Checks if string contains only alphanumeric characters (a-z, A-Z, 0-9)
method : public : IsAlphaNumeric() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if all characters are alphanumeric, false otherwise |
IsBlank #
Checks if the string is empty or contains only whitespace
method : public : IsBlank() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if blank, false otherwise |
IsEmpty #
Returns rather the string is empty
method : public : IsEmpty() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if empty, false otherwise |
Example
str := "";
if(str->IsEmpty()) {
"Empty string"->PrintLine();
};IsFloat #
Checks to see if the string can be represented as an float
method : public : IsFloat() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if the string can be represented as an float, false otherwise |
IsInt # native
Checks to see if the string can be represented as an interger
method : public : native : IsInt() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if the string can be represented as an interger, false otherwise |
IsNumeric #
Checks if string contains only numeric characters (0-9)
method : public : IsNumeric() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true if all characters are numeric, false otherwise |
Join # function
Joins an array of strings with a separator
function : Join(parts:String[], sep:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| parts | String | array of strings to join |
| sep | String | separator string |
Return
| Type | Description |
|---|---|
| String | joined string |
Justify #
Justify if word length is then width
method : public : Justify(width:Int, is_left:Bool) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| width | Int | width to justify to |
| is_left | Bool | if true, justify left, right otherwise |
Return
| Type | Description |
|---|---|
| String | padded string |
Last # native
Returns the last character
method : public : native : Last() ~ CharReturn
| Type | Description |
|---|---|
| Char | last character |
Lines # native
Splits a string into lines
method : public : native : Lines() ~ String[]Return
| Type | Description |
|---|---|
| String | array of lines |
New # constructor
Copy constructor
New(string:String)Parameters
| Name | Type | Description |
|---|---|---|
| string | String | string to be copied |
New # constructor
Copy constructor
New(array:Char[])Parameters
| Name | Type | Description |
|---|---|---|
| array | Char | array to be copied |
New # constructor
Constructor with initial capacity
New(capacity:Int)Parameters
| Name | Type | Description |
|---|---|---|
| capacity | Int | initial buffer capacity |
New # constructor
Copy constructor
New(array:Char[], copy:Bool)Parameters
| Name | Type | Description |
|---|---|---|
| array | Char | array to be copied |
| copy | Bool | if false, use array for value for string otherwise copy values |
New # constructor
Copy constructor
New(array:Char[], offset:Int, length:Int)Parameters
| Name | Type | Description |
|---|---|---|
| array | Char | array to be copied |
| offset | Int | offset array index offset |
| length | Int | number of characters to copy |
New # constructor
Copy constructor
New(bytes:Byte[])Parameters
| Name | Type | Description |
|---|---|---|
| bytes | Byte | array to be copied |
New # constructor
Copy constructor
New(bytes:Byte[], offset:Int, length:Int)Parameters
| Name | Type | Description |
|---|---|---|
| bytes | Byte | array to be copied |
| offset | Int | offset array index offset |
| length | Int | number of characters to copy |
Pad #
Pads a string with a character
method : public : Pad(char:Char, num:Int, is_left:Bool) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to pad with |
| num | Int | number of character to pad |
| is_left | Bool | if true, pad left, otherwise pad right |
Return
| Type | Description |
|---|---|
| String | padded string |
PadTo #
Pads the string with a fill character to a minimum total width. If the string is already at least 'width' long it is returned unchanged. Used by string-interpolation format specifiers, e.g. "{$n:05}" or "{$s:<10}".
method : public : PadTo(width:Int, ch:Char, is_left:Bool) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| width | Int | minimum total width |
| ch | Char | fill character |
| is_left | Bool | if true, pad on the left (right-justify); otherwise pad on the right |
Return
| Type | Description |
|---|---|
| String | padded string |
Example
"42"->PadTo(5, '0', true)->PrintLine(); # 00042
"hi"->PadTo(6, ' ', false)->PrintLine(); # 'hi 'Pop # native
Pops the last character from the string reducing the size by 1
method : public : native : Pop() ~ CharReturn
| Type | Description |
|---|---|
| Char | last character of the string |
PrintLine # function
Prints values
function : PrintLine(v:String[]) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| v | String | values to print |
Remove #
Removes the first occurrence the search string
method : public : Remove(find:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
Return
| Type | Description |
|---|---|
| String | new string instance |
Remove #
Removes the first occurrence of a character from a string
method : public : Remove(char:Char) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to remove |
Return
| Type | Description |
|---|---|
| String | string with first matching character removed |
RemoveAll #
Removes all occurrences the search string
method : public : RemoveAll(find:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
Return
| Type | Description |
|---|---|
| String | new string instance |
RemoveAll #
Removes all occurrences the search character
method : public : RemoveAll(find:Char) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| find | Char | character to search for |
Return
| Type | Description |
|---|---|
| String | new string instance |
Repeat #
Returns a string repeated n times
method : public : Repeat(n:Int) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| n | Int | number of repetitions |
Return
| Type | Description |
|---|---|
| String | repeated string |
Replace #
Replaces the first occurrence the search string
method : public : Replace(find:String, replace:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
| replace | String | string to replace with |
Return
| Type | Description |
|---|---|
| String | new string instance |
Example
result := "aabbcc"->Replace("bb", "XX");
result->PrintLine(); # aaXXccReplaceAll #
Replaces all occurrences the search string
method : public : ReplaceAll(find:String, replace:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| find | String | string to search for |
| replace | String | string to replace with |
Return
| Type | Description |
|---|---|
| String | new string instance |
Example
result := "cat and cat"->ReplaceAll("cat", "dog");
result->PrintLine(); # dog and dogReplaceAll # native
Replaces all occurrences the search string
method : public : native : ReplaceAll(find:Char, replace:Char) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| find | Char | character to search for |
| replace | Char | character to replace with |
Return
| Type | Description |
|---|---|
| String | new string instance |
Reverse # native
Reverses a string
method : public : native : Reverse() ~ StringReturn
| Type | Description |
|---|---|
| String | reversed string |
Example
"Hello"->Reverse()->PrintLine(); # olleHSet #
Sets character at the given index
method : public : Set(char:Char, index:Int) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| char | Char | charter to set |
| index | Int | index offset |
Return
| Type | Description |
|---|---|
| Bool | true if successful, false otherwise |
SetFloatFormat # function
Set floating point string format.
function : SetFloatFormat(format:Number->Format) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| format | Number->Format | float format |
SetFloatPrecision # function
Set floating point string precision.
function : SetFloatPrecision(precision:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| precision | Int | decimal precision |
SetIntFormat # function
Set integer string format.
function : SetIntFormat(format:Number->Format) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| format | Number->Format | integer format |
Size #
Return the size of the string
method : public : Size() ~ IntReturn
| Type | Description |
|---|---|
| Int | size of the string |
Example
"Hello"->Size()->PrintLine(); # 5Split #
Splits a string based upon delimiter
method : public : Split(delim:String) ~ String[]Parameters
| Name | Type | Description |
|---|---|---|
| delim | String | splitting delimiter |
Return
| Type | Description |
|---|---|
| String | array of split sub strings |
Example
parts := "one,two,three"->Split(",");
each(part in parts) {
part->PrintLine();
};Split #
Splits a string based upon delimiter
method : public : Split(delim:Char) ~ String[]Parameters
| Name | Type | Description |
|---|---|---|
| delim | Char | splitting delimiter |
Return
| Type | Description |
|---|---|
| String | array of split sub strings |
Example
parts := "a:b:c"->Split(':');
parts->Size()->PrintLine(); # 3StartsWith #
Checks if the string starts with the given character
method : public : StartsWith(char:Char) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| char | Char | character to compare |
Return
| Type | Description |
|---|---|
| Bool | true if starts with character, false otherwise |
Example
if("https://example.com"->StartsWith('h')) {
"Starts with h"->PrintLine();
};StartsWith #
Checks if the string starts with the given string
method : public : StartsWith(string:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| string | String | string to check for |
Return
| Type | Description |
|---|---|
| Bool | true if starts with string, false otherwise |
Example
url := "https://example.com";
if(url->StartsWith("https://")) {
"Secure"->PrintLine();
};StartsWithIgnoreCase #
Checks if the string starts with the given string, ignoring case
method : public : StartsWithIgnoreCase(string:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| string | String | string to check for |
Return
| Type | Description |
|---|---|
| Bool | true if starts with string, false otherwise |
SubString #
Creates a sub-string
method : public : SubString(length:Int) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| length | Int | max length of sub-string |
Return
| Type | Description |
|---|---|
| String | sub-string |
Example
tail := "Hello World"->SubString(5);
tail->PrintLine(); # HelloSubString #
Creates a sub-string
method : public : SubString(offset:Int, length:Int) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| offset | Int | index offset |
| length | Int | max length of sub-string |
Return
| Type | Description |
|---|---|
| String | sub-string |
Example
sub := "Hello World"->SubString(6, 5);
sub->PrintLine(); # WorldToBool #
Parses the string into a boolean
method : public : ToBool() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | boolean value |
ToByteArray # native
Returns a byte array representation of the String
method : public : native : ToByteArray() ~ Byte[]Return
| Type | Description |
|---|---|
| Byte | byte array |
ToCharArray #
Returns a character array representation of the String
method : public : ToCharArray() ~ Char[]Return
| Type | Description |
|---|---|
| Char | character array |
ToFloat #
Parses the string into a float
method : public : ToFloat() ~ FloatReturn
| Type | Description |
|---|---|
| Float | float value |
Example
f := "3.14"->ToFloat();
(f * 2.0)->PrintLine(); # 6.28ToInt #
Parses the string into an integer
method : public : ToInt() ~ IntReturn
| Type | Description |
|---|---|
| Int | integer value |
Example
n := "42"->ToInt();
(n * 2)->PrintLine(); # 84ToInt #
Parses the string into an integer
method : public : ToInt(base:Int) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| base | Int | base radix |
Return
| Type | Description |
|---|---|
| Int | integer value |
ToLower # native
Transforms a to lower case
method : public : native : ToLower() ~ StringReturn
| Type | Description |
|---|---|
| String | lower case string |
Example
"WORLD"->ToLower()->PrintLine(); # worldToString #
Returns string of self
method : public : ToString() ~ StringReturn
| Type | Description |
|---|---|
| String | string of self |
ToString # native
Formats an array of string
function : native : ToString(v:String[]) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| v | String | string array |
ToUpper # native
Transforms a to upper case
method : public : native : ToUpper() ~ StringReturn
| Type | Description |
|---|---|
| String | upper case string |
Example
"hello"->ToUpper()->PrintLine(); # HELLOTrim # native
Removes all leading and trailing white space
method : public : native : Trim() ~ StringReturn
| Type | Description |
|---|---|
| String | trimmed string |
Example
cleaned := " hello world "->Trim();
cleaned->PrintLine(); # hello worldTrimBack # native
Removes all trailing white space
method : public : native : TrimBack() ~ StringReturn
| Type | Description |
|---|---|
| String | trimmed string |
TrimChars #
Removes all leading and trailing occurrences of characters in the given set
method : public : TrimChars(chars:String) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| chars | String | string of characters to trim |
Return
| Type | Description |
|---|---|
| String | trimmed string |
TrimFront # native
Removes all leading white space
method : public : native : TrimFront() ~ StringReturn
| Type | Description |
|---|---|
| String | trimmed string |