Join Slack
Powered by
Suppose for a class ABC, what does fun ABC () mean...
# announcements
f
feroz_baig
06/14/2017, 3:21 AM
Suppose for a class ABC, what does fun ABC () mean? Constructor are defined in a different way in kotlin
a
agomez
06/14/2017, 3:33 AM
feroz_baig: it means an instance method named exactly like the class
agomez
06/14/2017, 3:33 AM
if you execute
ABC().ABC()
agomez
06/14/2017, 3:34 AM
first you are calling the constructor and then the instance method on the newly created object
f
feroz_baig
06/14/2017, 3:42 AM
@agomez
Should it be semantically correct. What If this fun is to be accessed via java code?
a
agomez
06/14/2017, 3:52 AM
in kotlin is correct, and i supposed from java will be valid to invoke
new ABC().ABC()
👍 1
r
radityagumay
06/14/2017, 3:53 AM
It will be a function, kolitn have their own primary constructor and secondary constructor
2
Views
Open in Slack
Previous
Next