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();

    // `s.length()` is same as `string:length(s)`.
    int m = string:length(s);

}

Langlib Functions

Langlib 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 ballerina/lang.T module for each built-in type T and they are automatically imported using T prefix.

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();

n will be 1.

    int m = string:length(s);

s.length() is same as string:length(s).

}
bal run langlib_functions.bal
b