Swan Lake Beta3 is here.
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
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
Subscribe to the newsletter

In the creation of Ballerina, we were inspired by so many technologies. Thank you to all that have come before us (and forgive us if we missed one): Java, Go, C, C++, D, Rust, Haskell, Kotlin, Dart, TypeScript, JavaScript, Python, Perl, Flow, Swift, Elm, RelaxNG, NPM, Crates, Maven, Gradle, Kubernetes, Docker, Envoy, Markdown, GitHub and WSO2.

Cookie Policy

This website uses cookies so that we can provide you with the best user experience. Read our Cookie Policy to find out more.

If you wish to disable cookies you can do so from your browser.

I Understand