lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>De: Pierre-Yves Gérardy <pygy79@gmail.com>
>Envoyé: Tue, 19 Nov 2013 10:55:07 +0100 (CET)
>
> On Mon, Nov 18, 2013 at 10:55 PM, Stéphane Aulery <lkppo@free.fr> wrote:
> > I do not know if this is doable, but I would find it convenient to name
> > the return values of functions to facilitate code maintenance.
> 
> Something like this?
> 
>     function add(a, b) returning c
>         c = a + b
>     end


Yes, or like that :

    function (s1, s2)add(a, b)
        s1 = a + b
        s2 = a * b
    end
    
    sum1, sum2 = add(3, 8)
    sum1, sum2 = (s1, s2)add(3, 8)
    sum2 = (s2)add(3, 8)

-- 
Stéphane Aulery