Java Style Guide: Call out that stateless lambdas are special.
Change-Id: I94c4c9fb89e6e33f2f87345218607a1ea772d800 Reviewed-on: https://chromium-review.googlesource.com/1212564 Commit-Queue: agrieve <agrieve@chromium.org> Reviewed-by: Ted Choc <tedchoc@chromium.org> Cr-Commit-Position: refs/heads/master@{#589572}
This commit is contained in:
@ -30,6 +30,9 @@ is encouraged, but there are some gotchas:
|
||||
|
||||
### Lambdas and Method References
|
||||
* These are syntactic sugar for creating anonymous inner classes.
|
||||
* Furthermore, stateless lambdas
|
||||
[become singletons](https://stackoverflow.com/questions/27524445/does-a-lambda-expression-create-an-object-on-the-heap-every-time-its-executed)
|
||||
and so do not result in new instances when used in loops.
|
||||
* Use them only where the cost of an extra class & method definition is
|
||||
justified.
|
||||
|
||||
|
Reference in New Issue
Block a user