[Gambas-user] Would an ArrayList datatype be helpful for gambas users?
gambas.fr at gmail.com
Sun Sep 10 23:03:18 CEST 2023
Le dim. 10 sept. 2023 à 22:54, Gianluigi <gradobag at gradobag.it> a écrit :
> Il 10/09/23 21:10, Martin Fischer ha scritto:
> >> I don't see the need of that as you can already use an array to do the
> >> same thing.
> >> Or maybe I missed something?
> > Benoit,
> > first I was confused about your reply...
> > Then I thought: He really should know...
> > Then I fired up gambas to find out if native arrays do already have the
> > convenience of my ArrayList...
> > And yes: you are right. Arrays resize automatically and have a "add to
> > tail" method (Add), and, and, and, ...
> > The only thing they do not have is the Slice (sublist view) stuff. But
> > that is surely not a justification to add another class.
> > I'm just wondering why I did not find this in the gambas-wiki. Is it
> > possible that this is basically undocumented?
> > Regards
> > Martin
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> Sorry Martin,
> I didn't understand what you mean by 'Slice', something like that?
> Public Sub Main()
> Dim aArr As String = ["A", "B", "C", "D", "E", "F", "G"]
> For Each s As String In aArr.Copy(3, 3)
> Print s
in langage like rust a slice is a kind of special pointer to an array or
any list with 3 coords like arrayref,position, length.
dim myarray as array = [...,...,...
dim mySlice as Slice = MyArray.Slice(2,23)
for each s in MySlice
I you change value in array then the value change also in the slice as it
is just a pointer to an array part.
It can be usefull on string analysis.
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the User