This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
/* | |
Primary Constructor Example | |
*/ | |
val primaryConstructorOnly = PrimaryConstructorOnly() | |
println("My name is ${primaryConstructorOnly.name}") | |
println("My age is ${primaryConstructorOnly.age}") | |
val primaryConstructorWithParams = PrimaryConstructorWithParams( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
/* | |
Without Extension Functions | |
if we are using a class "SomeThirdPartyClass" and | |
we want to add one more function, then | |
we need to inherit the "SomeThirdPartyClass" class with | |
"MyClass" and write that function inside it and | |
use "MyClass" everywhere instead of "SomeThirdPartyClass" class | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
/* | |
Without Extension Functions | |
if we are using a class "SomeThirdPartyClass" and | |
we want to add one more function, then | |
we need to inherit the "SomeThirdPartyClass" class with | |
"MyClass" and write that function inside it and | |
use "MyClass" everywhere instead of "SomeThirdPartyClass" class | |
*/ |
OlderNewer