How to use `apply` in Kotlin when property and function have the same variable name
data class Foo(
val aaa: String,
val bbb: String
)
fun bar(aaa: String) {
Foo().apply {
aaa = aaa // this line gives error
bbb = "bbb"
}
}
IDE gives an error Val cannot be reassigned which suggests it's trying to reassign the function level aaa.
how can I correctly use apply here to assign value of function level variable aaa to Foo's property aaa?