mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 21:18:31 +00:00
d6a4c14e1b
Full restructure of the spec into new sections for operators, statements, scripts, functions, lambdas, and regexes. Split of operators into 6 sections, a table, reference, array, numeric, boolean, and general. Clean up of all operators sections. Sporadic clean up else where.
15 lines
603 B
Plaintext
15 lines
603 B
Plaintext
[[painless-lambdas]]
|
|
=== Lambdas
|
|
Lambda expressions and method references work the same as in https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html[Java].
|
|
|
|
[source,painless]
|
|
---------------------------------------------------------
|
|
list.removeIf(item -> item == 2);
|
|
list.removeIf((int item) -> item == 2);
|
|
list.removeIf((int item) -> { item == 2 });
|
|
list.sort((x, y) -> x - y);
|
|
list.sort(Integer::compare);
|
|
---------------------------------------------------------
|
|
|
|
You can make method references to functions within the script with `this`,
|
|
for example `list.sort(this::mycompare)`. |