Meanwhile you could implement something like this in a module:
Public Function TrimLeft(extends s As String, characters() As String) As String
Var sizeBefore As Integer
sizeBefore = s.Length
For each char As String in characters
s = s.TrimLeft(char)
Loop Until sizeBefore = s.Length // removed all chars in the array
Var x As String = "abaacccbaXYZ"
x = x.TrimLeft(Array("a","b","c")) // x = XYZ
Use cases until now probably were well defined at design time, and using a small list of “chars”, so a hardcoded inline list as ParamArray offers should solve such necessity. If you have some special use case for dynamic list, I guess my method will help you and unlock your development. If you imagine more people will need it, a feature request should be made and such feature included in Xojo Standard library.
As I see it, the current issue is the other way around: when one has some parameters to pass (whose count is undefined at compile time) to methods which accept ParamArray, it would be nice to “automatically” be allowed to pass an array, so you can pass an arbitrary-sized list of parameters.
So the problem with that is that you wouldn’t know inside the method whether the array was the original array or not. Remember Arrays are objects so if you were to remove the last item from the array when called like this, you’d get two different results:
Dim arr() as String = array(1,2,3,4)
// arr = (1,2,3)
But calling it this way:
There’s no original array to manipulate. Talk about a potential bug that’s very hard to track down.
^ Again, this example is a ParamArray, not an Array, so I guess it internally composes a temporary array, a copy of such hardcoded parameters, that instead of being immutables due to be hardcoded literals, constants and not variables, they can be changed, as they are substituted by a temporary variable, but as a disposable copy, would not cause side effects.
But it’s not an error. Whether or not you pass an array byref is dependent on the form you use…
Sub MyMethod(arr() as string) // Array is passed (ByRef)
Sub MyMethod(paramArray arr as string) // Array is Created (ByVal)
There’s no error to catch at runtime because there’s nothing going wrong.
What I’m saying is that if Xojo were to automagically generate a separate matching method whenever you created one of these, the behavior between them would be different and very hard to explain.
Now, what Xojo could do here is give you a way in the IDE to create the other method, possibly by right-clicking the method in the navigator. But it’s not going to always be available. Paramarrays can only be placed at the end of a parameter list, whereas an array can be anywhere.
But there’s nothing wrong with that either. The array was created for you, just like any other ByVal parameter. Strings, Integers, Doubles, unless you specify ByRef, a new instance of the variable is created inside the method and you can change it as needed. Having paramarray behave differently would just be confusing, not to mention potentially breaking lots of code if a behavior change were made.