Is `agregar` or `añadir` (or something else) more correct when describing computer programming actions, for example when adding a string to an array?

    arr.append("hola")

Is that: 

    Agregar la cadena a la matriz

or:

    Añadir la cadena a la matriz

What about when describing adding a new function to a class?

    Agregue la nueva función a la clase Foo

Final situation: "`self` must be added as the first parameter"

    `self` debe añadirse como el primer parámetro