Strings¶
Datatypes and constructors¶
The datatype for strings is String.
String literals are enclosed in double quotes ("). Line feed in a
string literal is written as \n, carriage return as \r.
Operators¶
Expression |
Meaning |
Associativity |
Result type |
|---|---|---|---|
|
equality |
left |
Bool |
|
inequality |
left |
Bool |
|
less than |
left |
Bool |
|
less or equal |
left |
Bool |
|
greater than |
left |
Bool |
|
greater or equal |
left |
Bool |
|
concatenation |
left |
String |
Functions¶
toString¶
This function converts any data into a printable string representation.
toString(5)
// => "5"
toString(True)
// => "True"
substr¶
Returns a substring of a given string str with length length
starting from position start (inclusive). The first character in
a string has position 0.
substr("Hello world", 0, 5)
// => "Hello"
strlen¶
Returns the length of the given string str. The empty string
("") has length 0.
strlen("Hello")
// => 5
println¶
Prints the given string s to standard output, followed by a
newline, meaning that the next output will not continue on the same
line.
println("Hello")
// => Unit
// As a side effect, prints its argument to standard output
print¶
Prints the given string s to standard output. Does not cause the
next output to begin on a new line.
print("Hello")
// => Unit
// As a side effect, prints its argument to standard output