https://kotlinlang.org logo
a

A

01/12/2020, 7:50 PM
Can this be considered a Kotlin Vulnerability that if a
var name=<lambda>
is declared in a class, its returning value can be modified for a particular instance?This instance can be passed on to other functions which would end up with wrong data. I thought kotlin lambdas are supposed to be a clean looking replacement for functions, but functions do not change their logics. For eg:
d

Dico

01/12/2020, 8:00 PM
There are many ways of writing bad code. Using coding principles like Always use val unless you explicitly intend to modify it later, goes a long way to avoid it
d

Daniel

01/12/2020, 8:00 PM
Nothing special in my opinion. You can just as well make the name public var and change it from the outside. For the lambda the same, you are not changing the lambda, you provide a different one
d

Dico

01/12/2020, 8:01 PM
Intellij by default has an inspection suggesting not to use
var
unless you're actually using its functionality
3 Views