LoginSignup
1
1

More than 5 years have passed since last update.

Kotlin to Scala cheat sheet

Last updated at Posted at 2018-11-05

Kotlinをやったことがあって、Scalaをやったことがない人向けのシンタックスチートシート。
細かい動作の違いや仕様の違いは書いてません。

概念 Kotlin Scala
top level function object
companion object companion object object
Value Object data class case class
関数 fun def
forでの初期代入 in <-
range 0..10 0 to 10
forでの値飛ばし step, downTo by
パターンマッチ when ~ is match ~ case
インスタンス生成 Foo() new Foo
コンストラクタ constructor def this
インターフェース interface trait
ジェネリクス <T> [T]
変性 out, in +, -
lamda -> =>
nullable String? Option[String]
build tool gradle sbt(Scala Build Tool)
スコープ関数 with, apply, let, run, also 対応なし
拡張関数 fun クラス名.関数名() pimp my library
暗黙的な型変換など 対応なし implicit
関数の空実装 TODO() ???
formatter ktlint Scalafmt, Scalareform

Scalaでしかできないもので勉強した方がよさそうなこと

  • implicit
  • Pattern Match
  • モナド
1
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1