This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Modifier.shape(width: Dp, strokeBrush: Brush, fillColor: Color, shape: Shape): Modifier = composed( | |
factory = { | |
this.then( | |
when { | |
shape === RectangleShape -> rectangleModifier(width, strokeBrush, fillColor) | |
else -> shapeModifier(width, strokeBrush, fillColor, shape) | |
} | |
) | |
}, | |
inspectorInfo = debugInspectorInfo { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
using System; | |
using System.Reflection; | |
using Component = UnityEngine.Component; | |
namespace Editor.Customizations | |
{ | |
[CustomEditor(typeof(Transform))] | |
public class TransformCustomizedEditor : UnityEditor.Editor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun let<T1:Any,T2:Any,R>(p1: T1?, p2: T2?, body: (T1,T2)->R) : R?= if (t1 != null && t2 != null) body(t1,t2) else null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.jetbrains.akkatest | |
import akka.actor.* | |
import akka.routing.* | |
class Request | |
class Response | |
class Handler : UntypedActor() { | |
override fun onReceive(message: Any): Unit = when (message) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package x | |
fun fn(items: List<String?>) { | |
items.foreach(filter.notNull) { value -> | |
println("$value") | |
} | |
items.foreach(map.indexed) { (index,value) -> | |
println("$index $value") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait SelectResult<T> { | |
val take: Boolean | |
val value: T | |
class object { | |
fun take<T>(value: T) = object : SelectResult<T> { | |
override val value: T = value | |
override val take: Boolean = true | |
} | |
fun skip<T>() = object : SelectResult<T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JsonObject { | |
fun get(name : String) : JsonObject { | |
} | |
} | |
class JsonPathBuilder() { | |
fun String.div(name : String) : JsonPath { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event<T> { | |
typealias subscriber = (T)->Void | |
var subscribers = subscriber[]() | |
func subscribe(body : subscriber) { | |
subscribers.append(body) | |
} | |
func fire(value : T) { | |
for s in subscribers { | |
s(value) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instead of init-increment-condition "for" statement, we use for-each style: "for (x in 0..10)", compiler optimises as needed. | |
Declare immutable value with "val" and mutable variable with "var", either in class, function or top-level. | |
Missing 'With' from Delphi? :) Standard library has "public inline fun <T, R> with(receiver: T, f: T.() → R): R = receiver.f()" | |
I can't have no fact for today, because type system forbids me from passing null to not-null parameter. | |
Last functional argument of a method can be passed outside of parentheses: https://gist.github.com/orangy/11474248 <— "using statement" DSL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Injected<T> { | |
fun instance() : T | |
} | |
trait Imap { | |
class object : Injected<Imap> { | |
override fun instance(): Imap { | |
return ImapImpl() | |
} |
NewerOlder