Skip to content

Commit a3bfa2e

Browse files
committed
Add experimental fromNullable for explicit nulls
1 parent 95a8a9c commit a3bfa2e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/src/scala/runtime/stdLibPatches/Predef.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,8 @@ object Predef:
6262
* `eq` or `ne` methods, only `==` and `!=` inherited from `Any`. */
6363
inline def ne(inline y: AnyRef | Null): Boolean =
6464
!(x eq y)
65+
66+
extension (inline opt: Option.type)
67+
@experimental
68+
inline def fromNullable[T](t: T | Null): Option[T] = Option(t).asInstanceOf
6569
end Predef

0 commit comments

Comments
 (0)