import ballerina/io;function main (string[] args) {
    string ^"first name" = "John";
    string ^"last name" = "Gosling";
    string name = ^"combine names"(^"first name", ^"last name");
    io:println(name);
}
function ^"combine names" (string ^"first name",
                          string ^"last name") returns (string) {
    return ^"first name" + " " + ^"last name";
}
type ^"person record" {
    string ^"first name";
    string ^"last name";
    int age;
};

Identifier Literals

Ballerina supports Identifier literals, that means, it is possible to define symbols without restrictions like "no spaces, no special character" etc. in Ballerina.

import ballerina/io;
function main (string[] args) {
    string ^"first name" = "John";
    string ^"last name" = "Gosling";

The vertical bar (|) character is used to demarcate the identifier name. This is similar to string literals (using double quote characters to demarcate).

    string name = ^"combine names"(^"first name", ^"last name");
    io:println(name);
}

Invoking a function with identifier literal as a parameter.

function ^"combine names" (string ^"first name",
                          string ^"last name") returns (string) {
    return ^"first name" + " " + ^"last name";
}

Sample function defined with function name and input parameter using identifier literals.

type ^"person record" {
    string ^"first name";
    string ^"last name";
    int age;
};

Struct defined using identifier literals.

$ ballerina run identifier-literals.bal
John Gosling