Search code examples
dictionaryvala

Applying a function to every element of a vala array


What is the equivalent of the following python code

map(func, list)

in vala?


Solution

  • There's no such shortcut. You have to do a foreach:

    var res = new YourList ();
    foreach (var elem in list) res.add (func (elem));