Please explain use of Option's orNull method

后端 未结 5 771
北荒
北荒 2021-02-01 21:29

Scala\'s Option class has an orNull method, whose signature is shown below.

orNull [A1 >: A](implicit ev : <:<[Null, A1]) : A1
5条回答
  •  有刺的猬
    2021-02-01 21:42

    Remember that in Scala primitive types and reference types are unified - but only reference types are nullable. The implicit simply allows the compiler to confirm that A1 is a reference type.

提交回复
热议问题