Skip to content

Instantly share code, notes, and snippets.

View MasoudFallahpour's full-sized avatar

Masoud Fallahpour MasoudFallahpour

View GitHub Profile
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() {
class User {
var firstName: String by Delegate()
var lastName: String by Delegate()
}
fun main() {
val user = User().apply {
firstName = "John"
lastName = "Doe"
}
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
}
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")
fun main() {
val user = User().apply {
firstName = "John"
lastName = "Doe"
}
val firstName = user.firstName
val lastName = user.lastName
}
class User {
var firstName: String = ""
var lastName: String = ""
}
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;
}
class WordProcessor(software: Software) : Software by software
class WordProcessor(private val software: Software) : Software {
override fun getLicense(): String = software.getLicense()
}
class ProprietarySoftware : Software {
override fun getLicense() = "Some Proprietary Software License"
}
class FreeSoftware : Software {
override fun getLicense() = "Some Free Software License"
}