エントリーの編集
エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
Scalaの空括弧とUnit - Pixel Pedals of Tomakomai
Unit周りでハマったのでメモ。 まず、() => Any という型はあるが、()という型はない。 scala> def id(x... Unit周りでハマったのでメモ。 まず、() => Any という型はあるが、()という型はない。 scala> def id(x: () => Int): () => Int = x id: (x: () => Int)() => Int scala> def id(x: ()): () = x <console>:1: error: '=>' expected but ')' found. def id(x: ()): () = x ^ Unit型の唯一の要素が()である。 scala> ().isInstanceOf[Unit] res67: Boolean = true () => Any は Unit => Any とは違う。 // 型が違って代入できない scala> val emptyParentheses: () => Any = { () => 10 } emptyPar
2012/02/02 リンク