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
public final class User { | |
// $FF: synthetic field | |
static final KProperty[] $$delegatedProperties = new KProperty[]{(KProperty)Reflection.mutableProperty1(new MutablePropertyReference1Impl(User.class, "firstName", "getFirstName()Ljava/lang/String;", 0)), (KProperty)Reflection.mutableProperty1(new MutablePropertyReference1Impl(User.class, "lastName", "getLastName()Ljava/lang/String;", 0))}; | |
@NotNull | |
private final Delegate firstName$delegate = new Delegate(); | |
@NotNull | |
private final Delegate lastName$delegate = new Delegate(); | |
@NotNull | |
public final String getFirstName() { |
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
class User { | |
var firstName: String by Delegate() | |
var lastName: String by Delegate() | |
} | |
fun main() { | |
val user = User().apply { | |
firstName = "John" | |
lastName = "Doe" | |
} |
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
import kotlin.reflect.KProperty | |
class Delegate { | |
private var value: String = "" | |
operator fun getValue(thisRef: Any?, property: KProperty<*>): String { | |
println("${property.name} is read") | |
return value | |
} |
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() { | |
val user = User().apply { | |
println("firstName is written") | |
firstName = "John" | |
println("lastName is written") | |
lastName = "Doe" | |
} | |
println("firstName is read") | |
val firstName = user.firstName | |
println("lastName is read") |
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() { | |
val user = User().apply { | |
firstName = "John" | |
lastName = "Doe" | |
} | |
val firstName = user.firstName | |
val lastName = user.lastName | |
} |
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
class User { | |
var firstName: String = "" | |
var lastName: String = "" | |
} |
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
public final class WordProcessor implements Software { | |
// $FF: synthetic field | |
private final Software $$delegate_0; | |
public WordProcessor(@NotNull Software software) { | |
Intrinsics.checkNotNullParameter(software, "software"); | |
super(); | |
this.$$delegate_0 = software; | |
} |
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
class WordProcessor(software: Software) : Software by software |
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
class WordProcessor(private val software: Software) : Software { | |
override fun getLicense(): String = software.getLicense() | |
} |
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
class ProprietarySoftware : Software { | |
override fun getLicense() = "Some Proprietary Software License" | |
} | |
class FreeSoftware : Software { | |
override fun getLicense() = "Some Free Software License" | |
} |
NewerOlder