Function1

@implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.") trait Function1[@specialized -T1, @specialized +R] extends AnyRef

A function of 1 parameter.

In the following example, the definition of succ is a shorthand for the anonymous class definition anonfun1:

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.

Companion
object
Source
Function1.scala
class Object
trait Matchable
class Any
class From <:< To
class From =:= To
class Conversion[T, U]
trait MapOps[K, V, CC, C]
trait Map[K, V]
class AbstractMap[K, V]
class AbstractMap[K, V]
class HashMap[K, V]
class IntMap[T]
class ListMap[K, V]
class LongMap[T]
class Map1[K, V]
class Map2[K, V]
class Map3[K, V]
class Map4[K, V]
class WithDefault[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
class TreeSeqMap[K, V]
class VectorMap[K, V]
class AbstractMap[K, V]
class TrieMap[K, V]
class AnyRefMap[K, V]
class HashMap[K, V]
class LinkedHashMap[K, V]
class ListMap[K, V]
class LongMap[V]
class WithDefault[K, V]
class WithDefault[K, V]
class TreeMap[K, V]
trait DefaultMap[K, V]
trait SeqMap[K, V]
trait SeqMap[K, V]
trait SeqMap[K, V]
trait SortedMap[K, V]
trait SortedMap[K, V]
trait SortedMap[K, V]
trait Map[K, V]
trait Map[K, V]
trait Map[K, V]
trait MultiMap[K, V]
class WeakHashMap[K, V]
trait MapView[K, V]
class Filter[K, V]
class FilterKeys[K, V]
class Id[K, V]
class MapValues[K, V, W]
class TapEach[K, V, U]
trait SortedMapOps[K, V, CC, C]
trait SortedMapOps[K, V, CC, C]
trait SortedMapOps[K, V, CC, C]
trait MapOps[K, V, CC, C]
trait MapOps[K, V, CC, C]
trait Seq[A]
class AbstractSeq[A]
class AbstractSeq[A]
class ArraySeq[A]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
class LazyList[A]
class List[A]
class ::[A]
object Nil
class Exclusive[T]
class Inclusive[T]
class Queue[A]
class Range
class Exclusive
class Inclusive
class Stream[A]
class Cons[A]
object Empty
class Vector[A]
class AbstractSeq[A]
class ArrayBuffer[A]
class ArrayDeque[A]
class Queue[A]
class Stack[A]
class ListBuffer[A]
class ArraySeq[T]
class ofBoolean
class ofByte
class ofChar
class ofDouble
class ofFloat
class ofInt
class ofLong
class ofRef[T]
class ofShort
class ofUnit
trait IndexedSeq[A]
trait IndexedSeq[A]
trait IndexedSeq[T]
trait LinearSeq[A]
trait LinearSeq[A]
trait Seq[A]
trait Seq[A]
trait Buffer[A]
class Accumulator[A, CC, C]
trait SetOps[A, CC, C]
trait Set[A]
class AbstractSet[A]
class AbstractSet[A]
class ValueSet
class BitSet
class BitSet1
class BitSet2
class BitSetN
class HashSet[A]
class ListSet[A]
class Set1[A]
class Set2[A]
class Set3[A]
class Set4[A]
class TreeSet[A]
class AbstractSet[A]
class BitSet
class HashSet[A]
class TreeSet[A]
trait SortedSet[A]
trait BitSet
trait SortedSet[A]
trait SortedSet[A]
trait Set[A]
trait Set[A]
trait SortedSetOps[A, CC, C]
trait BitSetOps[C]
trait SortedSetOps[A, CC, C]
trait SortedSetOps[A, CC, C]
trait SetOps[A, CC, C]
trait SetOps[A, CC, C]
T1 => R

Value members

Abstract methods

def apply(v1: T1): R

Apply the body of this function to the argument.

Apply the body of this function to the argument.

Returns

the result of function application.

Source
Function1.scala

Concrete methods

def andThen[A](g: R => A): T1 => A

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 Params
A

the result type of function g

Value Params
g

a function R => A

Returns

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

Source
Function1.scala
def compose[A](g: A => T1): A => R

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 Params
A

the type to which function g can be applied

Value Params
g

a function A => T1

Returns

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

Source
Function1.scala
override def toString(): String
Definition Classes
Source
Function1.scala