Packages

trait IsIterableOnce[Repr] extends AnyRef

Type class witnessing that a collection representation type Repr has elements of type A and has a conversion to IterableOnce[A].

This type enables simple enrichment of IterableOnces with extension methods which can make full use of the mechanics of the Scala collections framework in their implementation.

Example usage,

class FilterMapImpl[Repr, I <: IsIterableOnce[Repr]](coll: Repr, it: I) {
  final def filterMap[B, That](f: it.A => Option[B])(implicit bf: BuildFrom[Repr, B, That]): That = {
    val b = bf.newBuilder(coll)
    for(e <- it(coll).iterator) f(e) foreach (b +=)
    b.result()
  }
}
implicit def filterMap[Repr](coll: Repr)(implicit it: IsIterableOnce[Repr]): FilterMapImpl[Repr, it.type] =
  new FilterMapImpl(coll, it)

List(1, 2, 3, 4, 5) filterMap (i => if(i % 2 == 0) Some(i) else None)
// == List(2, 4)
Source
IsIterableOnce.scala
Since

2.10

Linear Supertypes
Known Subclasses
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. IsIterableOnce
  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

Type Members

  1. abstract type A

    The type of elements we can traverse over (e.g.

    The type of elements we can traverse over (e.g. Int).

Abstract Value Members

  1. abstract def apply(coll: Repr): IterableOnce[A]

    A conversion from the representation type Repr to a IterableOnce[A].

Deprecated Value Members

  1. val conversion: (Repr) => IterableOnce[A]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) 'conversion' is now a method named 'apply'