2020-01-01から1ヶ月間の記事一覧

akka.pattern.RetrySupport

さんぷるのりとらい def retry[T](f: => Future[T]): Future[T] = { @tailrec def retry0(errors: List[Throwable], f: => Future[T]): Future[T] = { f.recoverWith { case e => run(e :: errors, f) } } run(Nil, f) } 末尾再帰になってない Future非同期…

Tuple

scala> :paste // Entering paste mode (ctrl-D to finish) val t1 = (1, 2) val t2 = 1 -> 2 val t3 = 1 → 2 val t4 = Tuple2(1,2) val t5 = Pair(1, 2) val t6 = Triple(1, 2, 3) // Exiting paste mode, now interpreting. <pastie>:15: warning: object Pair in </pastie>…

Mapができるまで

scalaパッケージ配下にいるMapたち package 共通 scala.collection 不変 scala.collection.immutable 可変 scala.collection.mutable scala> :paste // Entering paste mode (ctrl-D to finish) val im = Map("a" -> "A") // Exiting paste mode, now interp…

値渡し、無名関数、関数渡し

// docs // https://docs.scala-lang.org/tour/by-name-parameters.html def f0[T](f: T): T = f //値渡し def f1[T](f: => T): T = f //名前渡し def f2[T](f: () => T): T = f() //Function0 def f3[T](f: Function0[T]): T = f() //Function0 「名前渡し…

type

エイリアスをはれる type A = a.b.c.A val a: A = A() Cのtypedefみたいな。