not important, but just wondering... why are funct...
# announcements
h
not important, but just wondering... why are functions like
isNullOrEmpty()
not just an extension property so that the () are unnecessary? so that they can be overloaded? I usually create extensions for readability
g
so that they can be overloaded
I didn’t get what you mean.
h
i mean are they functions and not properties so that users can overload the function? it was a guess of mine
g
Overload?
Do you mean override?
h
yeah sorry!
g
“Overload” term usually applied to math operators
h
you're absolutely right
g
There is no difference between function and property in terms of overriding rules
And I still don’t understand what do you mean. You cannot override extension function/property. The only what you can do is add member function/property to class, such member will have higher priority than extension function
h
okay so i believe my question stands, then... why not omit the
()
and have it just be a property?
g
There is no very strict answer in this. Style guide has some attempts to distinguish between those cases, but not sure that they are applied in this case for property or for function choice
h
i'll try to be clearer; i write the following into many of my programs:
Copy code
val Collection.isNotEmpty get() = !this.isEmpty()
just because i think it looks and reads better
list.isNotEmpty
vs
list.isNotEmpty()
, not a bug difference for me
but I don’t see nothing wrong to use propery in this case
Just stdlib uses usually extension functions instead of extension properties
h
idk, i just always feel like less is more, and if the () are not needed for any purpose, i wanna drop them 😮
g
one more reason for that probably because inline extension functions supported from the beginning, but inline properties added only in Kotlin 1.1
h
righto. lots of exciting stuff coming in 1.3!
g
And isNotEmpty() is inlined