とSome(List("hello"))
を取得したい"hello"
場合、次の動作を観察しました。
scala> val list = Some(List("hello"))
list: Some[List[String]] = Some(List(hello))
scala> list.head.head
res3: String = hello
次に、Scaladocsを確認したところ、コレクションが空の場合に例外がスローさhead
れるSelect the first element of this iterable collection.
ことも指摘されています。
この Option[List] の最初の要素の取得は、慣用的と見なされますか?