I’m trying to apply a code optimisation suggestions provided by IntelliJ IDEA CE.
Below is a code sample:
(0 until 10).forEach {
val target = it
(10 until 20).forEach {
println(it + target)
}
}
Here IJ provides suggestion for variable target
on line 2 as “Variable is an exact copy of another variable and can be inlined” and after applying the suggestion code becomes:
(0 until 10).forEach {
(10 until 20).forEach {
println(it + it)
}
}
Wouldn’t it be better for nested sequences to have local parameters being passed to lambdas instead of relying on default parameter it
?