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/FunctionConverters

FunctionConverters

scala.jdk.FunctionConverters

This object provides extension methods that convert between Scala and Java function types.

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

Using the.asJava extension method on a Scala function produces the most specific possible Java function type:

scala> import scala.jdk.FunctionConverters._scala> val f = (x: Int) => x + 1scala> val jf1 = f.asJavajf1: java.util.function.IntUnaryOperator = ...

More generic Java function types can be created using the correspondingasJavaXYZ extension method:

scala> val jf2 = f.asJavaFunctionjf2: java.util.function.Function[Int,Int] = ...scala> val jf3 = f.asJavaUnaryOperatorjf3: java.util.function.UnaryOperator[Int] = ...

Converting a Java function to Scala is done using theasScala extension method:

scala> List(1,2,3).map(jf2.asScala)res1: List[Int] = List(2, 3, 4)

Attributes

Source
FunctionConverters.scala
Graph
Supertypes
Self type

Members list

Implicits

Inherited implicits

implicitdefenrichAsJavaBiConsumer[T,U](sf: (T,U)=>Unit):RichFunction2AsBiConsumer[T,U]
implicitdefenrichAsJavaBiFunction[T,U,R](sf: (T,U)=>R):RichFunction2AsBiFunction[T,U,R]
implicitdefenrichAsJavaBinaryOperator[T,A1,A2](sf: (T,A1)=>A2)(implicitevA1:A1=:=T,evA2:A2=:=T):RichFunction2AsBinaryOperator[T]
implicitdefenrichAsJavaDoubleFunction[A0,R](sf:A0=>R)(implicitevA0:A0=:=Double):RichFunction1AsDoubleFunction[R]
implicitdefenrichAsJavaFunction[T,R](sf:T=>R):RichFunction1AsFunction[T,R]
implicitdefenrichAsJavaIntBinaryOperator[A0,A1](sf: (A0,A1)=>Int)(implicitevA0:A0=:=Int,evA1:A1=:=Int):RichFunction2AsIntBinaryOperator
implicitdefenrichAsJavaIntConsumer[A0](sf:A0=>Unit)(implicitevA0:A0=:=Int):RichFunction1AsIntConsumer
implicitdefenrichAsJavaIntFunction[A0,R](sf:A0=>R)(implicitevA0:A0=:=Int):RichFunction1AsIntFunction[R]
implicitdefenrichAsJavaLongBinaryOperator[A0,A1](sf: (A0,A1)=>Long)(implicitevA0:A0=:=Long,evA1:A1=:=Long):RichFunction2AsLongBinaryOperator
implicitdefenrichAsJavaLongFunction[A0,R](sf:A0=>R)(implicitevA0:A0=:=Long):RichFunction1AsLongFunction[R]
implicitdefenrichAsJavaObjDoubleConsumer[T,A1](sf: (T,A1)=>Unit)(implicitevA1:A1=:=Double):RichFunction2AsObjDoubleConsumer[T]
implicitdefenrichAsJavaObjIntConsumer[T,A1](sf: (T,A1)=>Unit)(implicitevA1:A1=:=Int):RichFunction2AsObjIntConsumer[T]
implicitdefenrichAsJavaObjLongConsumer[T,A1](sf: (T,A1)=>Unit)(implicitevA1:A1=:=Long):RichFunction2AsObjLongConsumer[T]
implicitdefenrichAsJavaUnaryOperator[T,A1](sf:T=>A1)(implicitevA1:A1=:=T):RichFunction1AsUnaryOperator[T]
In this article
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL

[8]ページ先頭

©2009-2025 Movatter.jp