Scala Links - vpatryshev/wowiki GitHub Wiki

tools, env

optics

Training

Testing

Scala 3

akka

Scalaz

zio

Fury

types

cats

libraries

language

misc

SBT

ML

DeepLearning.scala

Snippets


object closable {
  type Closable = { def close }
  class Autoclose[A <: Closable](c: A){
    def foreach(f: A => Unit) = {
      try { f(c) }finally { c.close }
    }
  }
  implicit def autoClosable[A <: Closable](c: A) = new Autoclose(c)
//...
  case class Connection(name:String) {
    def close = println("closing " + this) 
  }
  case class Statement(c: Connection,q :String){
    def close = println("closing " + this)
    def exec = println("executing " + q + " on " + c)
  }
  def test = for(c <- Connection("conn"); 
		 st <- Statement(c,"select * from table")){
		   st.exec
		 }
}