Tutorial: Uso de Array (I)

He publicado un nuevo tutorial en vdeo en el canal de Xojo en YouTubesobre los Array (primera parte). Seguro que si ests empezando con Xojo te servir!

Cuando usas Arrays en tu cdigo no es lo mismo asignar los valores de un Array a otro que iterar y copiar los valores del Array fuente sobre el segundo.
En este vdeo podrs ver cual es la diferencia que te evitar quebraderos de cabeza:

https://www.youtube.com/watch?v=VBfkjiIrNtE

Javier

Hallo Javier

I never had headache on array handing over

global
dim a1(-1) As integer
dim a2(-1) as string

Dim r As New random
Dim i As Integer
For i = 0 To 100
a1.Append r.InRange(1,1000)
Next

rem stringArray = IntegerArray
a2 = neudata(a1)


Method neudata (b() as integer) as string()
Dim s(-1) As String
Dim t As String

For i As Integer = 0 To b.Ubound
t = "String " + b(i).ToText
s.Append t
Next

Return s

Hi Rudolf,

The point of the tutorial is explaining to Xojo language newcomers what they can expect when they assign an array (source) to another one (target); because probably they can think that the second array contains a “copy” of the objects stored in the source, when the fact is that when using the assignation operator what they get is a reference to the objects stored in the source, not a copy… So when an operation is done on the first array, this is reflected in the second one.

Then, the tutorial explains that if they really want to get a copy of the objects stored in the first array then they need to the iterate the source array and append those to the target one.

Javier

Aadida la entrada en el blog que explica “algo ms” sobre el tema :wink:

https://www.aprendexojo.com/2019/09/arrayentiende-la-diferencia-entre-asignacion-vs-copia/

Javier