string? maybeName = "Jane"; maybeName = (); // nil function divide(int a, int b) returns int|error if b == 0 return error("Division by zero");
Ballerina has powerful query expressions and type casts . ballerina
type Employee record string name; int salary; ; Employee[] employees = [ name: "Alice", salary: 5000 , name: "Bob", salary: 6000 ]; string
worker w2 returns int return 20;
(inside a function):
Call:
import ballerina/http; import ballerina/io; public function main() returns error? http:Client client = check new ("https://jsonplaceholder.typicode.com"); json response = check client->get("/posts/1"); io:println(response); string? maybeName = "Jane"