import ballerina/io;
public function main() {
string name = "James";
// Concatenates `Hello, ` strings with the `name` value.
string s1 = string`Hello, ${name}`;
io:println(s1);
// Concatenates `Backtick:` strings with `.
string s2 = string`Backtick:${"`"}`;
io:println(s2);
}
Backtick templatesThe backtick templates consist of a tag followed by characters surrounded by backticks. They can contain
Phase 2 for string... converts expressions to strings and concatenates. base16 and base64
tags do not allow expressions .
|
import ballerina/io;
public function main() {
string name = "James";
string s1 = string`Hello, ${name}`;
io:println(s1);
Concatenates Hello,
strings with the name
value.
string s2 = string`Backtick:${"`"}`;
io:println(s2);
}
Concatenates Backtick:
strings with `.
bal run backtick_templates.bal
Hello, James
Backtick:`