Swan Lake Beta2 is here.
import ballerina/io;

// Defines a type named `MapArray`.
type MapArray map<string>[];

public function main() {
    // Creates a `MapArray` value.
    // `arr` has elements which are of `map<string>` type.
    MapArray arr = [
        {"x": "foo"},
        {"y": "bar"}
    ];

    io:println(arr[0]);
}

Type Definitions

A type definition gives a name for a type. Its name is just an alias for the type, like typedef in C.

import ballerina/io;
type MapArray map<string>[];

Defines a type named MapArray.

public function main() {
    MapArray arr = [
        {"x": "foo"},
        {"y": "bar"}
    ];

Creates a MapArray value. arr has elements which are of map<string> type.

    io:println(arr[0]);
}
bal run type_definitions.bal
{"x":"foo"}
import ballerina/io;

// Defines a type named `MapArray`.
type MapArray map<string>[];

public function main() {
    // Creates a `MapArray` value.
    // `arr` has elements which are of `map<string>` type.
    MapArray arr = [
        {"x": "foo"},
        {"y": "bar"}
    ];

    io:println(arr[0]);
}

Type Definitions

A type definition gives a name for a type. Its name is just an alias for the type, like typedef in C.

import ballerina/io;
type MapArray map<string>[];

Defines a type named MapArray.

public function main() {
    MapArray arr = [
        {"x": "foo"},
        {"y": "bar"}
    ];

Creates a MapArray value. arr has elements which are of map<string> type.

    io:println(arr[0]);
}
bal run type_definitions.bal
{"x":"foo"}

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