Skip to content

Instantly share code, notes, and snippets.

@noncom
noncom / inheritance.kt
Created February 8, 2018 09:16
A thought on inheritance...
interface Data<T: Data> {
companion object {
abstract fun decode(encoded: Encoded): T
}
}
class Coords2D : Data<Coords2D> {
companion object {
fun decode(encoded: Encoded): Coords2D {
...
@noncom
noncom / ExtFunInf.kt
Last active February 7, 2018 09:31
Kotlin extension function receiver type inference
fun Int.one(x: Int) = this + 1 + x
fun Int.two(x: Int) = this + 2 + x
fun Int.three(x: Int) = this + 3 + x
fun Int.noop(x: Int) = this + x
class Z(val action: Int.() -> Int)
2018-01-15 01:39:51.598 [nettyCallPool-4-3] ERROR ktor.application - 101 Switching Protocols: GET - /ws/0
java.lang.NoSuchMethodError: kotlinx.coroutines.experimental.channels.ActorKt.actor(Lkotlin/coroutines/experimental/CoroutineContext;ILkotlinx/coroutines/experimental/CoroutineStart;Lkotlin/jvm/functions/Function2;)Lkotlinx/coroutines/experimental/channels/SendChannel;
at io.ktor.websocket.WebSocketWriter.<init>(WebSocketWriter.kt:10)
at io.ktor.websocket.RawWebSocketImpl.<init>(RawWebSocketImpl.kt:18)
at io.ktor.websocket.WebSocketUpgrade.upgrade(WebSocketUpgrade.kt:37)
at io.ktor.server.netty.http1.NettyHttp1ApplicationResponse.respondUpgrade(NettyHttp1ApplicationResponse.kt:69)
at io.ktor.server.engine.BaseApplicationResponse.respondOutgoingContent$suspendImpl(BaseApplicationResponse.kt:62)
at io.ktor.server.engine.BaseApplicationResponse.respondOutgoingContent(BaseApplicationResponse.kt)
at io.ktor.server.netty.NettyApplicationResponse.respondOutgoingContent$suspendImpl(NettyApplicationResponse
(let [fs [+ - *]
cbd [c b d]
m (x a b c d)]
(for [f1 fs f2 fs f3 fs,
o-1 cbd o-2 cbd o-3 cbd]
(let [res (f1 (f2 (f3 m o-1) o-2) o-3)]
[(make res a) [f1 f2 f3] [o-1 o-2 o-3] res])))