Skip to content

Support for lambda expressions #26

@wcmjunior

Description

@wcmjunior

Since Android M and Android Studio 2.1 have full support for lambda expressions in Java 8, the compiler should be able to handle them. In fact, the user-library was primarily designed to allow functionality transmission, which is basically to enable users to inject its code by instantiating an anonymous object and implementing the function method. Though improvements should be performed in the user-library, it is not necessary to change a single line of code to use the existing structure of function classes (Foreach, Reduce, Map and Filter) as lambda expressions. I have already tested the user-library in Java 8 and it worked fine (and neat!) as I created lambda expressions like:

// Reduce
Int32 ret = array.reduce((element1, element2) -> {
    element1.value += element2.value;
    return element1;
});
// Map
Array<Int16> array2 = array.map(Int16.class, (element -> {
    return new Int16((short) (element.value + 10));
}));
// Foreach
array2.foreach(element -> {
    element.value += 1;
});
// Filter
Array<Int32> array3 = array.filter(element -> {
    return element.value > 10;
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions