Skip to content

Instantly share code, notes, and snippets.

View erokhins's full-sized avatar

Stanislav Erokhin erokhins

  • JetBrains
  • Amsterdam
View GitHub Profile
open class A(open val bar: Int = 5) {
{
println("A: " + bar)
}
}
class B(override val bar: Int = 2) : A() {
{
println("B: " + bar)
@erokhins
erokhins / gist:6021366
Last active December 19, 2015 21:39
Kara new
open class TagAttributes
var TagAttributes.id = ""
class Tag<out T: TagAttributes>(val containingTag: Tag<TagAttributes>?, val t: T) {
val attr: T = t
fun attr(f: T.() -> Unit) {
}
}
public final class Attrs<out T: HtmlTag>(tag: T): AbstractCommonAttribute<Attrs<T>>(tag)
open class A(containingTag: HtmlBodyTag): AllowText, HtmlBodyTag(containingTag, "a") {
// public final class Attrs(htmlTag: HtmlTag): AbstractCommonAttribute<Attrs>(htmlTag)
public open val attr: Attrs<A> = Attrs(this)
}
public var Attrs<A>.href: Link by Attributes.href
class A1: A("") {
trait A {
private fun foo()
fun bar() {
foo()
}
}
class B: A {}
fun main(args: Array<String>) {
trait I<T> {
public fun invoke(f: T.() -> Unit) {}
}
open class A: I<A> {
val c1 = 1
}
class B: I<B> {
@erokhins
erokhins / gist:5983361
Created July 12, 2013 10:15
C.foo D.foo
open class A {
val c1 = 1
}
class B: A() {
val c2 = 2
}
open class C
open class D: C()
@erokhins
erokhins / gist:5977265
Created July 11, 2013 17:04
Kara.StrEnum
val autocomplete = StrEnumAttribute("autocomplete", javaClass<Autocomplete>())
public class Autocomplete(override val value: String): StrEnumValues<Autocomplete> {
val off = Autocomplete("off")
val on = Autocomplete("on")
}
@erokhins
erokhins / gist:5976177
Last active December 19, 2015 15:29
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>()
open class Attributes {
var name = "No name"
var time = "10:00"
fun invoke(f : Attributes.() -> Unit) {
this.f()
}
}
class A {
class A_ATTR: Attributes() {
@erokhins
erokhins / gist:5964612
Created July 10, 2013 08:55
Kara.attr
open class Attributes {
var name = "No name"
var time = "10:00"
}
class A {
val attr = object: Attributes() {
var href = ""
}
}