Like Kotlin, Swift supports implicit self/this. I ...
# announcements
t
Like Kotlin, Swift supports implicit self/this. I ran a poll over in the Swift forums to see who embraced implicit, and who embraced explicit. I honestly expected implicit to be +95%. I was surprised that the breakdown was 29% explict, 71% implicit, out of 140 votes. I'm curious what the breakdown is in the Kotlin crowd. Poll: Implicit this = 🔵 (
:large_blue_circle:
), Explicit this = 🟩 (
:large_green_square:
)
🔵 40
🟩 1
a
What is the difference between both ?
b
this.someProp (explicit) vs someProp (implicit)
👍 1
b
for simple accessors i use explicit, for more complex code i prefer implicit
n
I don't know about swift but in Kotlin, implicit this is a bit of a way of life, it's a big part of what makes the dsls work
4
💯 5
y
To add to Nir's point, it is especially useful when you have multiple receivers in the same scope because you don't need a whole ugly
this@MyScopeNameOrWhateverTheHeck