Skip to content

Instantly share code, notes, and snippets.

@erokhins
Last active December 19, 2015 15:29
Show Gist options
  • Save erokhins/5976177 to your computer and use it in GitHub Desktop.
Save erokhins/5976177 to your computer and use it in GitHub Desktop.
kara.attributes
abstract class Attributes<T> {
var name = "No name"
var time = "10:00"
fun invoke(f: T.() -> Unit) {
(this as T).f()
}
}
class CommonAttributes: Attributes<CommonAttributes>()
class A {
class InnerAttributes : Attributes<InnerAttributes>() {
var href = ""
}
val attr = InnerAttributes()
}
class TABLE {
class InnerAttributes : Attributes<InnerAttributes>() {
var height = 10
}
val attr = InnerAttributes()
}
fun TABLE.tr(content: TR.() -> Unit) {}
class TR {
val attr = CommonAttributes()
}
abstract class Attributes {
var name = "No name"
var time = "10:00"
}
class CommonAttributes: Attributes() {
fun invoke(f: CommonAttributes.() -> Unit) {
this.f()
}
}
class A {
class InnerAttributes : Attributes() {
var href = ""
fun invoke(f: InnerAttributes.() -> Unit) {
this.f()
}
}
val attr = InnerAttributes()
}
class TABLE {
class InnerAttributes : Attributes() {
var height = 10
fun invoke(f: InnerAttributes.() -> Unit) {
this.f()
}
}
val attr = InnerAttributes()
}
fun TABLE.tr(content: TR.() -> Unit) {}
class TR {
val attr = CommonAttributes()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment