What is best way to reset an array back to -1 elements?

xojo need a simple way to add alias names for methods.
Arrays.RemoveAll Alias Clear
Arrays.RemoveAll Alias Empty
Arrays.RemoveAll Alias New
and the Precompiler translate it back.

Sure, what a gift to those who will have to maintain othersā€™ code :exploding_head:.

The reason why dim is (kind of) replaced by var, is that it didnā€™t make sense with redim. If I recall what Geoff wrote about that is that in the past, in Basic only arrays were dimmed, and it was possible to redim an array. Using var is a great way to modernize Xojoā€™s Basic.

Those who thinks Xojo changes way to fast should have a look at C#.

maintain othersā€™ code is :exploding_head:.
generally. var have a different meaning in c# which is mainstream. local or def would be a better name. btw in a team you could make a agreement.

Xojo could change less, whatever C# do.

1 Like

Because Empty() could just as easily be a test to see if the array was empty:

if MyArray.Empty() then
   // Do something
end if

Also, as others have already pointed out ResizeTo can be used to make the array larger or smaller and not just empty.

In that case it should be named IsEmpty.

3 Likes