is it idiomatic to avoid the use of `this` when p...
# getting-started
y
is it idiomatic to avoid the use of
this
when possible?
👌 9
s
not whenever possible, at least in my code. I don't use it in member functions, but totally in extension functions, both when I write them and if I provide a lambda to them, e.g. in
apply
.
y
okay. because coming from other languages, I like the explicitness of keeping it.
m
You can use it, it all depends on the code style adopted by the project you’re working on. If it is your project, then you can do however you please.
🫡 1
j
If it is your project, then you can do however you please.
The same goes for everything related to code-style, but that's not very helpful to the initial discussion. The question was which code style was idiomatic. In Java and Kotlin, we usually don't write
this
explicitly unless we need to.
j
ie if the member we're trying to access is shadowed by a local variable