Swan Lake Beta2 is here.
import ballerina/io;
// The `@display` annotation applies to the transform function.
@display {
    label: "Transform",
    iconPath: "transform.png"
}
public function transform(string s) returns string {
   return s.toUpperAscii();
}

public function main() {
    // The `@strand` annotation applies to the `start` action.
    future<int> fut = @strand { thread: "any" } start foo();

    int|error x = wait fut;
    io:println(x);
}

public function foo() returns int {
    return 10;
}

Annotations

Annotations start with @tag and they come before what they apply to. Unprefixed tags refer to standard platform-defined annotations and Prefixed tags refer to annotations declared in modules. @tag can be followed by record constructor expression.

import ballerina/io;
@display {
    label: "Transform",
    iconPath: "transform.png"
}
public function transform(string s) returns string {
   return s.toUpperAscii();
}

The @display annotation applies to the transform function.

public function main() {
    future<int> fut = @strand { thread: "any" } start foo();

The @strand annotation applies to the start action.

    int|error x = wait fut;
    io:println(x);
}
public function foo() returns int {
    return 10;
}
bal run annotations.bal
10
import ballerina/io;
// The `@display` annotation applies to the transform function.
@display {
    label: "Transform",
    iconPath: "transform.png"
}
public function transform(string s) returns string {
   return s.toUpperAscii();
}

public function main() {
    // The `@strand` annotation applies to the `start` action.
    future<int> fut = @strand { thread: "any" } start foo();

    int|error x = wait fut;
    io:println(x);
}

public function foo() returns int {
    return 10;
}

Annotations

Annotations start with @tag and they come before what they apply to. Unprefixed tags refer to standard platform-defined annotations and Prefixed tags refer to annotations declared in modules. @tag can be followed by record constructor expression.

import ballerina/io;
@display {
    label: "Transform",
    iconPath: "transform.png"
}
public function transform(string s) returns string {
   return s.toUpperAscii();
}

The @display annotation applies to the transform function.

public function main() {
    future<int> fut = @strand { thread: "any" } start foo();

The @strand annotation applies to the start action.

    int|error x = wait fut;
    io:println(x);
}
public function foo() returns int {
    return 10;
}
bal run annotations.bal
10

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