Packages

t

scala

Function1

trait Function1[-T1, +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.

Self Type
(T1) ⇒ R
Annotations
@implicitNotFound( msg = ... )
Source
Function1.scala
Linear Supertypes
Known Subclasses
ValueSet, PartialFunction, <:<, =:=, AbstractMap, AbstractSeq, AbstractSet, BitSet, BitSetLike, DefaultMap, GenSet, GenSetLike, IndexedSeq, LinearSeq, Map, WithDefault, MapLike, DefaultKeySet, FilteredKeys, MappedValues, Seq, SeqView, SeqViewLike, Appended, DroppedWhile, EmptyView, Filtered, FlatMapped, Forced, Mapped, Patched, Prepended, Reversed, Sliced, TakenWhile, Transformed, Zipped, ZippedAll, Set, SetLike, SortedMap, SortedMapLike, DefaultKeySortedSet, SortedSet, SortedSetLike, Map, TrieMap, ::, AbstractMap, BitSet, BitSet1, BitSet2, BitSetN, DefaultMap, HashMap, HashMap1, HashTrieMap, HashSet, HashTrieSet, IndexedSeq, Impl, IntMap, LinearSeq, List, ListMap, Node, ListSet, Node, LongMap, Map, Map1, Map2, Map3, Map4, WithDefault, MapLike, ImmutableDefaultKeySet, Nil, NumericRange, Exclusive, Inclusive, Queue, Range, Inclusive, Seq, Set, Set1, Set2, Set3, Set4, SortedMap, DefaultKeySortedSet, SortedSet, Stream, Cons, Empty, StreamView, StreamViewLike, Appended, DroppedWhile, EmptyView, Filtered, FlatMapped, Forced, Mapped, Patched, Prepended, Reversed, Sliced, TakenWhile, Transformed, Zipped, ZippedAll, TreeMap, TreeSet, Vector, WrappedString, AbstractBuffer, AbstractMap, AbstractSeq, AbstractSet, AbstractSortedMap, AbstractSortedSet, AnyRefMap, ArrayBuffer, ArraySeq, ArrayStack, BitSet, Buffer, HashMap, HashSet, IndexedSeq, IndexedSeqView, DroppedWhile, Filtered, Reversed, Sliced, TakenWhile, Transformed, LinearSeq, LinkedHashMap, DefaultKeySet, FilteredKeys, MappedValues, LinkedHashSet, ListBuffer, ListMap, LongMap, Map, WithDefault, MapLike, MultiMap, MutableList, OpenHashMap, Queue, ResizableArray, Seq, Set, SetLike, SortedMap, SortedSet, StringBuilder, TreeMap, TreeSet, UnrolledBuffer, WrappedArray, ofBoolean, ofByte, ofChar, ofDouble, ofFloat, ofInt, ofLong, ofRef, ofShort, ofUnit, DefaultKeySet, ParSet, ParSetLike, ParHashSet, ParSet, ParHashSet, ParSet, ParSetLike, AbstractFunction1, AbstractPartialFunction, SystemProperties, MapProxy, MapProxyLike, SeqProxy, SetProxy, SetProxyLike, SeqForwarder, MapProxy, PagedSeq, SetProxy, Stack, BufferProxy, DefaultMapModel, DoubleLinkedList, ImmutableMapAdaptor, ImmutableSetAdaptor, LinkedList, MapProxy, ObservableBuffer, ObservableMap, ObservableSet, QueueProxy, SetProxy, Stack, StackProxy, SynchronizedBuffer, SynchronizedMap, SynchronizedQueue, SynchronizedSet, SynchronizedStack, Script, MurmurHash
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Function1
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract 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.

Concrete Value Members

  1. 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.

    A

    the result type of function g

    g

    a function R => A

    returns

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

    Annotations
    @unspecialized()
  2. 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.

    A

    the type to which function g can be applied

    g

    a function A => T1

    returns

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

    Annotations
    @unspecialized()
  3. def toString(): String

    Creates a String representation of this object.

    Creates a String representation of this object. The default representation is platform dependent. On the java platform it is the concatenation of the class name, "@", and the object's hashcode in hexadecimal.

    returns

    a String representation of the object.

    Definition Classes
    Function1 → AnyRef → Any