How do I check if a string contains a substring?
Closed this issue · 3 comments
Xh4H commented
Topic.
I've tried:
var test = "a";
var contains = test.includes("a");
But that errors... So... any ideas?
clegoz commented
That's happening because test
variable is a String[T]
but includes
method is expecting non-generic String
.
Here's an example to demonstrate:
namespace NSMain;
function stringTest(str: String): Bool {
return true;
}
function stringTest2(str: String[T]): Bool {
return true;
}
entrypoint function main(): Bool {
var test = "Test";
//return stringTest(test); // This will throw exception.
//return stringTest2(test); // This is OK.
}
I'll make a PR request which should fix the issue.
mrkmarron commented
Xh4H commented
Alright thank you