以下、勉強した内容です。
Scala
implicit
implicit class
をConsoleで宣言すると、implicit modifies cannot be used for top level object.
と言われるが、実行はできる。"pimp my library"のpimpの意味が「ポン引きなどの売春斡旋業者」…
1.to(2)
のto
メソッドは、RichInt
クラスに定義されている。
List(1, 2, 3, 4).sum
のsum
はimplicit parameterの用法
- クラス定義:
trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
- メソッド定義:
def sum[B >: A](implicit num: Numeric[B]): B = foldLeft(num.zero)(num.plus)
分からなかった練習問題
List[Int] と List[Double] のsumを行うために、標準ライブラリでは何という型クラス(1つ)と型クラスのインスタンス(2つ)を定義しているかを、Scala標準ライブラリから探して挙げなさい。
- 型クラスが
Numeric
であることは、sum
のメソッドに(implicit num: Numeric[B])
と書かれていることから、理解できた。 - 型クラスインスタンスが
IntIsIntegral
やDoubleAsIfIntegral
である理由が分からない。
型クラスへの誘い
- よく分からなかった
FutureとPromise
- FutureのonCompleteでSuccessとFailureの処理を分けた
- FutureはOptionと同じような使い方ができる
Intellij IDEA
Ctrl+B
で移動した後、戻るにはCtrl+Alt+Left
を押す。
Keyboard shortcut for Jump to Previous View Location (Navigate back/forward) in IntelliJ IDEA - Stack OverflowIntellij IDEAでtooltipに表示されたエラー一覧をどう表示するか? https://youtrack.jetbrains.com/issue/IDEA-65636#comment=27-1800459 How do I copy and paste the tooltip error message that pops up in IntelliJ IDEA? - Stack Overflow how to copy some text from tooltip messages to clipboard – IDEs Support (IntelliJ Platform) | JetBrains