Closed ivan-mogilko closed 5 months ago
I agree, it's a good convenience for several cases.
It misses the actual flags, but I believe the gist of the changes would be something like this
https://github.com/ericoporto/ags/commit/de5d29cd1d2f339dcaa8ca75336fe98b933a2e12
Not sure if there is a pretty way to get the trim in a single function.
Uhm, I wonder if a string like " , , , ,"
is passed with both flags, what the result should be, would it be null or does an empty array exists in AGS script?
The trim implementation from above commit looks fine, similar to what I've imagined. (I'd only use camelcase function names similar to all names around, according to our code style)
Uhm, I wonder if a string like
" , , , ,"
is passed with both flags, what the result should be, would it be null or does an empty array exists in AGS script?
AGS does not currently allow creating a zero-length dynamic array in script (with the new
operator). But if this is a matter of convenience, we may investigate if it's possible to support such array, and return one. In fact, maybe it's already technically possible.
I put a PR in #2461, please test it!
Resolved by #2461
I propose to add optional "split options" as a set of flags for the String.Split methods, equivalent or similar to the C# library function: https://learn.microsoft.com/en-us/dotnet/api/system.stringsplitoptions?view=net-8.0
Something like