[Gambas-user] Would an ArrayList datatype be helpful for gambas users?

Gianluigi gradobag at gradobag.it
Mon Sep 11 18:27:01 CEST 2023


Il 11/09/23 17:37, T Lee Davidson ha scritto:
> On 9/11/23 04:18, Gianluigi wrote:
>> You made me want to check out Bjarne Stroustrup's book.
>>
>> Slice is well explained, unfortunately it is 'way' beyond my mental 
>> capabilities.
>>
>
> I have to doubt, Gianluigi, that slices are beyond your comprehension. 
> They are actually not complex. Perhaps that book's explanation was 
> rather convoluted.
>
> A slice is, simply stated, a limited view of an array.
>
> Suppose we could do this:
>
> Dim aStrings As String[] = ["one", "two", "three", "four", "five", 
> "six", "seven"]
> Dim aSlice As Slice = aStrings.Slice(2, 3) ' Syntax equals 
> Slice(startIndex, Length) [ Except in Python :-\ ]
>
> The slice's view of the underlying array would consist of only the 
> values ["three", "four", "five"] and would be indexed starting at zero.
>
> Print aSlice[1] ' Would print "four"
>
> Since a slice is not a copy of a subset of an array (but holds a 
> reference to the underlying array), changing a value in the slice also 
> changes the referenced value in the array:
>
> aSlice[1] = "nine"
> ' aStrings now equals ["one", "two", "three", "nine", "five", "six", 
> "seven"]
>
> See? Simple. (But, I may not have explained it very well either.)
>
He Lee,

Now I can say I really understand and yes, it is not difficult.
Fabien tried to explain it to me but for my mind he was too hurried.
But he can afford it, since he participates in the production of that 
divine nectar called Cognac :-)

Thank you all

Regards

Gianluigi




More information about the User mailing list