Tutorial: Uso de Array (I)

  1. 5 weeks ago

    Javier M

    Sep 12 Pre-Release Testers, Xojo Pro, Third Party Store AprendeXojo - Europe, Spain

    He publicado un nuevo tutorial en vídeo en el canal de Xojo en YouTube… sobre los Array (primera parte). Seguro que si estás empezando con Xojo te servirá!

    Cuando usas Arrays en tu código 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 vídeo podrás ver cual es la diferencia que te evitará quebraderos de cabeza:

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

    Javier

  2. 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

  3. Javier M

    Sep 12 Pre-Release Testers, Xojo Pro, Third Party Store AprendeXojo - Europe, Spain

    @Rudolf J I never had headache on array handing over

    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

  4. Javier M

    Sep 16 Pre-Release Testers, Xojo Pro, Third Party Store AprendeXojo - Europe, Spain

    Añadida la entrada en el blog que explica "algo más" sobre el tema ;-)

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

    Javier

or Sign Up to reply!