This file contains hidden or 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
| extension [A, B] (t: Tuple2[A, B]) | |
| inline infix def ||>[C](inline f: (A, B) => C): C = | |
| f(t._1, t._2) | |
| extension [T] (t: T) | |
| infix def |>[B](f: T => B): B = | |
| f(t) | |
| def add(a:Int, b: Int):String = (a + b).toString |
This file contains hidden or 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
| open System | |
| open FreeRedis | |
| // Define a function to construct a message to print | |
| let from whom = sprintf "from %s" whom | |
| let inline (|>!) x sideEffect = | |
| do sideEffect x | |
| x |
This file contains hidden or 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
| import scala.jdk.CollectionConverters._ | |
| import scala.util.chaining._ | |
| case class Myforable[A](v: List[A]): | |
| def foreach[T](f: A => T): Unit = v.foreach(f) | |
| def map[T](f: A => T): Myforable[T] = Myforable(v.map(f)) | |
| def flatMap[T](f: A => Myforable[T]): Myforable[T] = | |
| val list: List[T] = v.map(f).map(_.v).flatten |
This file contains hidden or 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
| sealed trait Metric(val name: String, val description: String) | |
| case class Counter(override val name: String, | |
| override val description: String, | |
| value: Double | |
| ) extends Metric(name, description) | |
| trait ToText[T <: Metric]: | |
| def toText(t: T): String |
This file contains hidden or 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
| import scala.language.{dynamics, unsafeNulls} | |
| class DynamicBO(m: Map[String, Any]) extends Selectable, Dynamic { | |
| def selectDynamic(name: String): Any = m.getOrElse(name, null) | |
| } | |
| type User = DynamicBO {val name: String; val age: Int} | |
| abstract class BaseDynamic extends Dynamic |
This file contains hidden or 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
| extension[T] (t: T) | |
| infix inline def |>[B](block: T => B): B = block(t) | |
| infix inline def <|(block: T => Unit): T = | |
| block(t) | |
| t | |
| enum Opt[+T]: | |
| case Empty | |
| case Box(t: T) |
This file contains hidden or 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
| private def print_type_tree(clazz: Class[?], level: Int = 0): Unit = | |
| if clazz != null then | |
| println((" " * level) + clazz) | |
| val nextLevel = level + 2 | |
| clazz.getInterfaces.foreach(it => print_type_tree(it, nextLevel)) | |
| print_type_tree(clazz.getSuperclass, nextLevel) |
This file contains hidden or 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
| import { | |
| desc as description, | |
| run, | |
| sh, | |
| shCapture, | |
| task, | |
| } from "https://deno.land/x/[email protected]/mod.ts"; | |
| interface DevEnvTask { | |
| name: string; |
This file contains hidden or 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
| import java.util.{Date as JDate} | |
| import scala.io.Source as S | |
| trait JsonOps[T] { | |
| def stringify(t: T): String | |
| extension (x:T) def toJSON(): String = stringify(x) | |
| } | |
| given intJsonOps: JsonOps[Int] with { |
This file contains hidden or 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 example | |
| import scala.scalajs.js | |
| class C(val a: String, val b: Boolean, val c: Int) extends js.Object | |
| object C { | |
| def apply(a: String, b: Boolean, c: Int): C = new C(a, b, c) | |
| } |
NewerOlder