Skip to content

Instantly share code, notes, and snippets.

View adam-arold's full-sized avatar
💭
Exploring the n'th dimension.

Adam Arold adam-arold

💭
Exploring the n'th dimension.
View GitHub Profile
interface Component {
val children: Iterable<Component>
fun requestFocus()
fun clearFocus()
}
class MyComponent(
override val children: Iterable<Component>,
val drawSurface: DrawSurface) : Component {
class MyComponent(
val children: Iterable<Component>, // 1
internal val drawSurface: DrawSurface) { // 2
fun requestFocus() {
}
fun clearFocus() {
}
class MyComponent(
val children: List<MyComponent>, // 1
internal val drawSurface: PixelGraphicsImpl) { // 2
fun requestFocus() {
}
fun clearFocus() {
}
class MyComponent(
val isFocused: Boolean,
val children: List<MyComponent>,
val drawSurface: PixelGraphicsImpl) {
fun requestFocus() {
}
fun clearFocus() {
}
class Tile
fun writeTile(tile: Tile) =
println("Tile: $tile")
writeTile(Tile())
class Tile:
pass
def write_tile(tile: Tile):
print("Tile: " + str(tile))
write_tile(Tile())
public final class SomeClass {
// $FF: synthetic field
static final KProperty[] $$delegatedProperties = new KProperty[]{(KProperty)Reflection.mutableProperty1(new MutablePropertyReference1Impl(Reflection.getOrCreateKotlinClass(SomeClass.class), "someValue", "getSomeValue()Ljava/lang/String;"))};
@NotNull
private final ReadWriteProperty someValue$delegate = NotNullVarKt.notNull();
@NotNull
public final String getSomeValue() {
return (String)this.someValue$delegate.getValue(this, $$delegatedProperties[0]);
}
class SomeClass {
var someValue: String by notNull()
}
public fun <T : Any> notNull(): ReadWriteProperty<Any?, T> = NotNullVar()
class NotNullVar<T : Any> : ReadWriteProperty<Any?, T> {
private var value: T? = null
public override fun getValue(thisRef: Any?, property: KProperty<*>): T {
return value ?: throw IllegalStateException("Property ${property.name} should be initialized before get.")
}
public override fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
this.value = value
}