Movatterモバイル変換


[0]ホーム

URL:


Scala 3
3.7.4
LearnInstallPlaygroundFind A LibraryCommunityBlog
Scala 3
LearnInstallPlaygroundFind A LibraryCommunityBlog
DocsAPI
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
Scala 3/scala/scala.jdk/OptionConverters

OptionConverters

scala.jdk.OptionConverters

This object provides extension methods that convert between ScalaOption and JavaOptional types.

When writing Java code, use the explicit conversion methods defined injavaapi.OptionConverters instead.

ScalaOption is extended with atoJava method that creates a correspondingOptional, and atoJavaPrimitive method that creates a specialized variant (e.g.,OptionalInt) if applicable.

JavaOptional is extended with atoScala method and atoJavaPrimitive method.

Finally, specializedOptional types are extended withtoScala andtoJavaGeneric methods.

Example usage:

import scala.jdk.OptionConverters._val a = Option("example").toJava      // Creates java.util.Optional[String] containing "example"val b = (None: Option[String]).toJava // Creates an empty java.util.Optional[String]val c = a.toScala                     // Back to Option("example")val d = b.toScala                     // Back to None typed as Option[String]val e = Option(2.7).toJava            // java.util.Optional[Double] containing boxed 2.7val f = Option(2.7).toJavaPrimitive   // java.util.OptionalDouble containing 2.7 (not boxed)val g = f.toScala                     // Back to Option(2.7)val h = f.toJavaGeneric               // Same as eval i = e.toJavaPrimitive             // Same as f

Attributes

Source
OptionConverters.scala
Graph
Supertypes
classObject
traitMatchable
classAny
Self type

Members list

Type members

Classlikes

final implicitclassRichOption[A](o:Option[A]) extendsAnyVal

Provides conversions from ScalaOption to JavaOptional types

Provides conversions from ScalaOption to JavaOptional types

Attributes

Source
OptionConverters.scala
Supertypes
classAnyVal
traitMatchable
classAny
final implicitclassRichOptional[A](o:Optional[A]) extendsAnyVal

Provides conversions from JavaOptional to ScalaOption and specializedOptional types

Provides conversions from JavaOptional to ScalaOption and specializedOptional types

Attributes

Source
OptionConverters.scala
Supertypes
classAnyVal
traitMatchable
classAny
final implicitclassRichOptionalDouble(o:OptionalDouble) extendsAnyVal

Provides conversions fromOptionalDouble to ScalaOption and the genericOptional

Provides conversions fromOptionalDouble to ScalaOption and the genericOptional

Attributes

Source
OptionConverters.scala
Supertypes
classAnyVal
traitMatchable
classAny
final implicitclassRichOptionalInt(o:OptionalInt) extendsAnyVal

Provides conversions fromOptionalInt to ScalaOption and the genericOptional

Provides conversions fromOptionalInt to ScalaOption and the genericOptional

Attributes

Source
OptionConverters.scala
Supertypes
classAnyVal
traitMatchable
classAny
final implicitclassRichOptionalLong(o:OptionalLong) extendsAnyVal

Provides conversions fromOptionalLong to ScalaOption and the genericOptional

Provides conversions fromOptionalLong to ScalaOption and the genericOptional

Attributes

Source
OptionConverters.scala
Supertypes
classAnyVal
traitMatchable
classAny

Implicits

Implicits

implicitdefRichOption[A](o:Option[A]):RichOption[A]

Provides conversions from ScalaOption to JavaOptional types

Provides conversions from ScalaOption to JavaOptional types

Attributes

Source
OptionConverters.scala
implicitdefRichOptional[A](o:Optional[A]):RichOptional[A]

Provides conversions from JavaOptional to ScalaOption and specializedOptional types

Provides conversions from JavaOptional to ScalaOption and specializedOptional types

Attributes

Source
OptionConverters.scala

Provides conversions fromOptionalDouble to ScalaOption and the genericOptional

Provides conversions fromOptionalDouble to ScalaOption and the genericOptional

Attributes

Source
OptionConverters.scala

Provides conversions fromOptionalInt to ScalaOption and the genericOptional

Provides conversions fromOptionalInt to ScalaOption and the genericOptional

Attributes

Source
OptionConverters.scala

Provides conversions fromOptionalLong to ScalaOption and the genericOptional

Provides conversions fromOptionalLong to ScalaOption and the genericOptional

Attributes

Source
OptionConverters.scala
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp