A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.scala-lang.org/api/current/scala/Function1.html below:

Function1

scala.Function1

See theFunction1 companion object

A function of 1 parameter.

In the following example, the definition of succ is shorthand, conceptually, for the anonymous class definition anonfun1, although the implementation details of how the function value is constructed may differ:

object Main extends App {
  val succ = (x: Int) => x + 1
  val anonfun1 = new Function1[Int, Int] {
    def apply(x: Int): Int = x + 1
  }
  assert(succ(0) == anonfun1(0))
}

Note that the difference between Function1 and scala.PartialFunction is that the latter can specify inputs which it will not handle.

Attributes
Companion
object
Source
Function1.scala
Graph
Supertypes
Known subtypes

trait

MapOps

[

K

,

V

,

CC

,

C

]

trait

MapOps

[

K

,

V

,

CC

,

C

]

trait

MapOps

[

K

,

V

,

CC

,

C

]

Show all
Self type
Members list

Apply the body of this function to the argument.

Apply the body of this function to the argument.

Attributes
Returns

the result of function application.

Source
Function1.scala

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters
A

the result type of function g

Value parameters
g

a function R => A

Attributes
Returns

a new function f such that f(x) == g(apply(x))

Source
Function1.scala

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters
A

the type to which function g can be applied

Value parameters
g

a function A => T1

Attributes
Returns

a new function f such that f(x) == apply(g(x))

Source
Function1.scala

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes
Returns

a string representation of the object.

Definition Classes
Source
Function1.scala

Converts an optional function to a partial function.

Converts an optional function to a partial function.

Attributes
Example

Unlike Function.unlift, this UnliftOps.unlift method can be used in extractors.

val of: Int => Option[String] = { i =>
  if (i == 2) {
    Some("matched by an optional function")
  } else {
    None
  }
}
util.Random.nextInt(4) match {
  case of.unlift(m) => // Convert an optional function to a pattern
    println(m)
  case _ =>
    println("Not matched")
}
Source
Function1.scala

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4