Skip to content

Commit

Permalink
Add an iterator() alias to iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrf committed Mar 28, 2018
1 parent fcc3425 commit 88da007
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/scala-2.12/collection/compat/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ package object compat {
def fromSpecific(source: TraversableOnce[Int]): C = fact.apply(source.toSeq: _*)
}

implicit class WithParens[A](private val as: IterableLike[A, _]) extends AnyVal {
def iterator(): Iterator[A] = as.iterator
}

// This really belongs into scala.collection but there's already a package object in scala-library so we can't add to it
type IterableOnce[+X] = TraversableOnce[X]
}
14 changes: 14 additions & 0 deletions src/test/scala/collection/IterableLikeTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package collection

import org.junit.Test

import scala.collection.compat._

class IterableLikeTest {

@Test
def iteratorTest(): Unit = {
List(1, 2, 3).iterator()
}

}

0 comments on commit 88da007

Please sign in to comment.