Klitos Kyriacou
04/03/2025, 4:25 PM(some+complicated+expression).let { value ->
when (value) {
...
}
}
Is there any automated refactoring available to simplify it to this?
when (val value = some+complicated+expression) {
...
}
Anna Kozlova
04/03/2025, 6:06 PMKotlin | Redundant constructs | Redundant receiver-based 'let' call
which provides a fix to remove redundant let
, though it seems, it doesn't work in all cases. Could you please provide the full code snippet to check? ThanksKlitos Kyriacou
04/04/2025, 8:56 AMfun main(args: Array<String>) {
(args.size * 100 + 10).let { println(it) } // "Redundant 'let' call could be removed"
(args.size * 100 + 10).let { // No inspection offered
when (it) {
10 -> println("a")
110 -> println("b")
else -> println("c")
}
}
}