Reputation: 1214
I'm trying the basics with the following code:
import ballerina/io;
import ballerina/stringutils;
public function main() {
string str1 = "Comparing String";
string str2 = "cOmpaRinG sTrinG";
io:print("String '" + str1 + "' and '" + str2 + "' are");
if (stringutils:equalsIgnoreCase(str1, str2)) {
io:println(" equal");
} else {
io:println(" not equal");
}
}
But I get an error:
caio@german_shepherd test % bal run ./string.bal
Compiling source
string.bal
ERROR [string.bal:(2:1,2:30)] cannot resolve module 'ballerina/stringutils'
ERROR [string.bal:(8:9,8:49)] undefined function 'equalsIgnoreCase'
ERROR [string.bal:(8:9,8:49)] undefined module 'stringutils'
error: compilation contains errors
caio@german_shepherd test % bal -v
Ballerina Swan Lake Beta 2
Language specification 2021R1
Update Tool 1.3.5
caio@german_shepherd test % sudo bal dist use slbeta2
Password:
'slbeta2' is the current active distribution version
I see the same error while editing the code on VSC. What is missing?
Upvotes: 1
Views: 133
Reputation: 1122
ballerina/stringutils
module is removed with Swan Lake Beta 1 release. The "regex" related APIs were moved to ballerina/regex
[1] module and rest of the APIs are available at langlib string library [2].
Therefore we need to update your code sample as follows:
import ballerina/io;
public function main() {
string str1 = "Comparing String";
string str2 = "cOmpaRinG sTrinG";
io:print("String '" + str1 + "' and '" + str2 + "' are");
if ('string:equalsIgnoreCaseAscii(str1, str2)) {
io:println(" equal");
} else {
io:println(" not equal");
}
}
[1] https://lib.ballerina.io/ballerina/regex/latest
[2] https://lib.ballerina.io/ballerina/lang.string/latest
Upvotes: 2