import ballerina/io;
public function main() {
// You can call langlib functions using the method-call syntax.
string s = "abc".substring(1, 2);
io:println(s);
// `n` will be 1.
int n = s.length();
io:println(n);
// `s.length()` is same as `string:length(s)`.
int m = string:length(s);
io:println(m);
}
Langlib functionsLanglib is a small library defined by language providing fundamental operations on built-in data types.
Langlib functions can be called using convenient method-call syntax, but these types are not objects!
There exists a |
import ballerina/io;
public function main() {
string s = "abc".substring(1, 2);
You can call langlib functions using the method-call syntax.
io:println(s);
int n = s.length();
io:println(n);
n
will be 1.
int m = string:length(s);
io:println(m);
s.length()
is same as string:length(s)
.
}
bal run langlib_functions.bal
b
1
1