Swan Lake Beta3 is here.
// Port on which to run the service.
configurable int port = 8080;

//`configurable string password = ?;`
//
// This specifies that the password must be supplied in a configuration file.

Configurable Variables

A module-level variable can be declared as configurable. The initializer of a configurable variable can be overridden at runtime (e.g., by a TOML file). A variable where configuration is required can use an initializer of ?. The type of a configurable variable must be subtype of anydata.

For more information, see Making Ballerina Programs Configurable.

configurable int port = 8080;

Port on which to run the service.

configurable string password = ?;

This specifies that the password must be supplied in a configuration file.

bal run configurable_variables.bal
// Port on which to run the service.
configurable int port = 8080;

//`configurable string password = ?;`
//
// This specifies that the password must be supplied in a configuration file.

Configurable Variables

A module-level variable can be declared as configurable. The initializer of a configurable variable can be overridden at runtime (e.g., by a TOML file). A variable where configuration is required can use an initializer of ?. The type of a configurable variable must be subtype of anydata.

For more information, see Making Ballerina Programs Configurable.

configurable int port = 8080;

Port on which to run the service.

configurable string password = ?;

This specifies that the password must be supplied in a configuration file.

bal run configurable_variables.bal
Subscribe to the newsletter

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