google-java-format icon indicating copy to clipboard operation
google-java-format copied to clipboard

Remove parentheses for single parameter lambda

Open honnix opened this issue 3 years ago • 2 comments

I understand this is probably against the design philosophy, but I would like to get it confirmed if that is the case.

It is generally considered to be a bette practice omitting parentheses for single parameter lambda, for example foo -> ... is better than (foo) -> ..., from readability perspective.

I tried hacking around and could get it to work, but I had to ignore a token by adding a new method to OpsBuilder, so either I'm doing something wrong or this is very much against the design philosophy (respecting original input as much as possible, IIUC).

Could you please help me understand whether this is a valid feature request or not? Thank you very much.

honnix avatar Mar 09 '22 16:03 honnix

A uniform approach such as consistently using parentheses ( ) regardless of the number of parameters definitely provides more clarity. The following is not logically consistent. ( ) 0 x 1 (x, y) 2+

i-zanis avatar Oct 03 '23 22:10 i-zanis

I'm kinda OK with either approach but I would like to have consistency.

honnix avatar Oct 04 '23 18:10 honnix