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/collection/generic/IsIterableOnce.html below:

IsIterableOnce

scala.collection.generic.IsIterableOnce

See theIsIterableOnce companion object

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)
Attributes
Companion
object
Source
IsIterableOnce.scala
Graph
Supertypes
Known subtypes
Members list

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

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

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

Attributes
Source
IsIterableOnce.scala
Attributes
Deprecated
[Since version 2.13.0] \'conversion\' is now a method named \'apply\'
Source
IsIterableOnce.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