Add asOptionalInt and etc to stdlib?

  private def toOptionalInt(input: Option[Int]): OptionalInt = input match {
    case Some(value) => OptionalInt.of(value)
    case None => OptionalInt.empty

currently, there is only asJava which returns Optional<Integer>


Welcome to Scala 2.13.14 (OpenJDK 64-Bit Server VM, Java 21.0.2).
Type in expressions for evaluation. Or try :help.

scala> import jdk.OptionConverters._
       error: object OptionConverters is not a member of package jdk

scala> import scala.jdk.OptionConverters._
import scala.jdk.OptionConverters._

scala> val x = Option(42)
val x: Option[Int] = Some(42)

scala> x.toJavaPrimitive
val res0: java.util.OptionalInt = OptionalInt[42]


Thanks, totally missed that

1 Like