SAM-constructors for Iterable and Sequence interfaces.

This commit is contained in:
Ilya Gorbunov
2016-02-02 01:36:58 +03:00
parent 947fd84f1e
commit f19ef6e3d5
8 changed files with 45 additions and 122 deletions
@@ -1884,11 +1884,7 @@ public inline fun <T> Iterable<T>.asIterable(): Iterable<T> {
* Creates a [Sequence] instance that wraps the original collection returning its elements when being iterated.
*/
public fun <T> Iterable<T>.asSequence(): Sequence<T> {
return object : Sequence<T> {
override fun iterator(): Iterator<T> {
return this@asSequence.iterator()
}
}
return Sequence { this.iterator() }
}
/**