5
smnp.text
Bartłomiej Przemysław Pluta edited this page 2020-04-02 09:19:13 +02:00

Methods

string.find

string.find(char: string)

Returns index of given character in string and -1 if value not exist.

string.isEmpty

string.isEmpty()

Checks if length of string is equal to 0.

string.isNotEmpty

string.isNotEmpty()

Checks if length of string is greater than 0.

string.toInt

string.toInt()

Tries to convert string to int. If the text actually represents an int, it returns it as of int type. It returns itself (as a string) otherwise.

string.substring

string.substring(startIndex: int, endIndex: int)

Returns a substring.

Example

println("Hello world".substring(1, 5));    # ello

string.split

string.split(delimiter: string)

Splits the string with given delimiter to list of strings and returns it.

Example

str = "this:is:some:text";

println(str.split(":"));    # [this, is, some, text]

string.toFloat

string.toFloat()

Tries to convert string to float. If the text actually represents a float, it returns it as of float type. It returns itself (as a string) otherwise.

string.toBool

string.toBool()

Tries to convert string to bool. If the text actually is equal to "true" or "false", it returns it as of bool type. It returns itself (as a string) otherwise.

string.toNote

string.toNote()

Tries to convert string to note. If the text actually represents a note, it returns it as of note type. It returns itself (as a string) otherwise.