Scalaライブラリ

Scala標準ライブラリ

https://www.scala-lang.org/api/current/scala/index.html


Mavenレポジトリ

https://mvnrepository.com/search?q=scala


scala.collection.immutable

https://www.scala-lang.org/api/current/scala/collection/immutable/index.html


scala.collection.mutable

https://www.scala-lang.org/api/current/scala/collection/mutable/index.html


Set

import scala.collection.immutable(or mutable etc...)

immurtable

mutable


Seq

繰り返し作業(シーケンス)を設定するトレイト。メンバーはSeqライブラリ参照のこと。

import scala.collection.immutable(or mutable etc...)

immutable

mutable


Vector

immutable


Option

Option/Some/None
Some, NoneはOptionのサブクラス。

Ex)

def toInt(s: String): Option[Int] = {
    try {
        Some(Integer.parseInt(s.trim))
    } catch {
        case e: Exception => None
    }
}

出力

入力がIntの時はSomeを返す。Stringの時はtoIntできないのでNoneを返す。

scala> val a = toInt("1")
a: Option[Int] = Some(1)

scala> val a = toInt("foo")
a: Option[Int] = None

SeqとListの違い

HOW ARE THE COLLECTIONS STRUCTURED? WHICH ONE SHOULD I CHOOSE?

Immutable Collections Diagram

Mutable Collections Diagram

scala-logging

https://github.com/lightbend/scala-logging

akka-actor-typed には slf4j-api が含まれています。