[Gambas-user] Array slicing - how is it done in Gambas?

Sebastian Kulesz sebikul at ...626...
Wed Oct 10 22:30:39 CEST 2012


On Wed, Oct 10, 2012 at 5:23 PM, RICHARD WALKER
<richard.j.walker at ...247...> wrote:
> Let's say I have a string array with 12 elements. I want to pass some
> of these to a function for processing. What notation do I use to
> specify, say, the "sub-array" comprising elements 6, 7 and 8 of the 12
> element array?
>
> At the moment I can only do it by creating a new array of appropriate
> size and copying the required elements into it. An equally ugly
> alterrnative would be to pass the whole array with a couple of index
> variables to define the limits. Or I could copy the whole array and
> delete the unwanted elements.
>
> I was really hoping that my_array[6 To 12] would work, but not in
> Gambas it seems.
>
> Richard
>
> ------------------------------------------------------------------------------
> Don't let slow site performance ruin your business. Deploy New Relic APM
> Deploy New Relic app performance management and know exactly
> what is happening inside your Ruby, Python, PHP, Java, and .NET app
> Try New Relic at no cost today and get our sweet Data Nerd shirt too!
> http://p.sf.net/sfu/newrelic-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user

String[].Copy or String[].Extract should do the job.

http://gambasdoc.org/help/comp/gb/string[]/copy?v3

http://gambasdoc.org/help/comp/gb/string[]/extract?v3




More information about the User mailing list