Re: [Vala] Lambda expression with arguments?



On 05/09/07, Mathias Hasselmann <mathias hasselmann gmx de> wrote:
Am Mittwoch, den 05.09.2007, 01:30 -0400 schrieb Michel Salim:
Hello,

All the examples on the Vala site involves using lambda expressions as
signal handlers. The expressions there take no parameters and return
void.

Getting a lambda expression to return something seems straightforward,
but how does one write a lambda expression that takes arguments? Can
the types of the parameters and return value be specified?

As the samples demonstrate arguments are passed like this:

    btn.clicked += b => {
        stdout.printf ("Click!\n");
    }

    s.notify += (s, p) => {
        stdout.printf ("Property `%s' changed\n", p.name); // [*]
    }

Thanks. Got confused by the AdvancedSample, which took an s and then
never used it.

-- 
Michel



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