Fields and properties
In the preceding example, I used a special function, TODO(), from the Kotlin standard library. This function is overloaded and has two implementations:
@kotlin.internal.InlineOnly
public inline fun TODO(): Nothing = throw NotImplementedError()
@kotlin.internal.InlineOnly
public inline fun TODO(reason: String): Nothing = throw NotImplementedError("An operation is not implemented: $reason")It's very useful when you're modeling a class and don't want to implement certain class members right away. You can also use it for methods, as shown in the following code:
fun click() {
TODO()
} And you can use it for constructors as well:
constructor() {
TODO()
}Let's look at how the Button class decompiled to Java:
public final class Button {
@NotNull
private String text;
private int backgroundColor;
@Nullable
private Function1 onClickListener;
@NotNull
public final String getText() {
return this.text;
}
public final void setText(@NotNull String var1) {
Intrinsics.checkParameterIsNotNull...