[Gambas-user] Remove Null or Empty items in arrays.

Jussi Lahtinen jussi.lahtinen at gmail.com
Wed Jun 21 18:46:16 CEST 2023


Almost always you can remove null or zero value when constructing the
array. This encourages bad habits.

Jussi

On Wed, Jun 21, 2023 at 7:37 PM Martín <mbelmonte at belmotek.net> wrote:

> El 21/6/23 a las 13:08, Bruce Steers escribió:
> > Public Sub ArrayClean(MyArray As Variant) As Variant
> >
> >   Dim hArray As Variant = MyArray.Copy()
> >   For c As Integer = hArray.Max DownTo 0
> >     If Not hArray[c] Then hArray.Remove(c)
> >   Next
> >
> >   Return hArray
> >
> > End
>
> I like this code you propose, thank you.
> But I was wondering, since there is .Shuffle or .Sort, maybe it would be
> a good idea to have .RemoveEmpty.
>
> Best regards.
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230621/dfc72552/attachment.htm>


More information about the User mailing list