android-studio-inspection.png
# announcements
n
android-studio-inspection.png
m
If the last argument to a method is a a lambda, it’s more idiomatic to use the syntax where the lambda is moved out of the list of arguments in parentheses. Prefer
Copy code
doSomething { }
Rather than
Copy code
doSomething({})
👆 1
l
you can use
alt + enter
to apply the “fix”
n
Isn’t there a difference between “can be moved out” and “should be moved out” ?
l
its not an error, so you don't have to do it 😉
l
it is also possible to disable the inspection from the
alt + enter
menu
👍 1
m
It’s just a convention that Kotlin style prefers for the lambda to be moved out
n
In this case of complex code, I think the parentheses serve as a visual boundary.
l
the style guide recommends:
If a call takes a single lambda, it should be passed outside of parentheses whenever possible.
https://kotlinlang.org/docs/reference/coding-conventions.html#lambda-formatting
n
@leolima In AS 3.1.4, the context menu with Alt+Enter has no option to silence the warning
l
that’s weird… it should be in the expanded menu
n
Oh well… We spent too much time on it already. AS 3.1 has plenty of bugs. I was forced to rollback to 3.0 twice.