This release has considered about further stabilizing previous release with bug fixing effort. Apart from that there is a major improvement on Websocket standard library with the introduction of supporting union type for pushText()
and multiple type support for onText()
functions. Also there are few language syntax changes.
The native
keyword has been changed to extern
due to Ballerina moving towards a model of native compilation. With this model, code will be an external library and everything is native. Libraries can be written or not written in Ballerina.
Old syntax:
public native function string::toUpper() returns string;
New syntax:
public extern function string::toUpper() returns string;
- Bitwise complement (~) operator inverts the bits of its operand expression. The static type of the operand must be int, and the static type of the result is an int.
int i = 387465;
int j = ~i;
- Introduce index based access for tuples. Elements of a tuple type can now be accessed via indexes as follows:
(boolean, int, string) x = (true, 3, "abc");
boolean tempBool = x[0];
string tempString = x[2];
x[1] = 4;
- The
pushText
function takes a union type instead of a string type. The new signature is as follows:
public function pushText(string|json|xml|boolean|int|float|byte|byte[] data, boolean final = true) returns error?
- The
onText
function can take a string, JSON, XML, record, or byte[] types instead of only string. TheonText
signature can be any one of the following:
onText(endpoint caller, string text, boolean final)
onText(endpoint caller, json jsonVal)
onText(endpoint caller, xml xmlVal)
onText(endpoint caller, Person person)
onText(endpoint caller, byte[] data)
Note: In the above code snippet, Person is a record type.
For all values except for string type, the values are aggregated if a continuation frame is received. Hence the value of final is not relevant in the case of other types except string.
- Sealed types source generation support.
- Nil lifting completion support.
Please see Github milestone for bug fixes.
You can download the Ballerina distributions, try samples, and read the documentation at https://ballerina.io. You can also visit the [Quick Tour] (https://ballerina.io/learn/quick-tour/) to get started. We encourage you to report issues, improvements, and suggestions at the Ballerina Github Repository.