Instantiate and add data to an array

How can I add an item with its "name" and "quantity" attributes, and at the same time instantiate a new "Purchase"?
My code is the following but it doesn't work.

def compraList = [];

//my bdm list
compra.compras[0] = {
    //compraList.add({
        def compraExt = new com.company.model.mantenimiento.Compra();
        compraExt.nombre = 'Mantenimiento externo';
        compraExt.cantidad = 1;
    })
}
return compraList;