Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix IsIterableLike example code #6751

Merged
merged 1 commit into from Jun 7, 2018
Merged

Conversation

xuwei-k
Copy link
Contributor

@xuwei-k xuwei-k commented Jun 7, 2018

use IterableOps instead of IterableLike. IterableLike does not exists.

Welcome to Scala 2.13.0-M4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_172).
Type in expressions for evaluation. Or try :help.

scala> :paste
// Entering paste mode (ctrl-D to finish)

import scala.collection.Iterable
import scala.collection.generic.IsIterableLike

class ExtensionMethods[A, Repr](coll: IterableLike[A, Repr]) {
  def mapReduce[B](mapper: A => B)(reducer: (B, B) => B): B = {
    val iter = coll.toIterator
    var res = mapper(iter.next())
    while (iter.hasNext)
      res = reducer(res, mapper(iter.next()))
    res
  }
}
// Exiting paste mode, now interpreting.

       class ExtensionMethods[A, Repr](coll: IterableLike[A, Repr]) {
                                             ^
On line 4: error: not found: type IterableLike

use iterator instead of toIterator

@deprecated("toIterator has been renamed to iterator", "2.13.0")
@`inline` def toIterator: Iterator[A] = it.iterator

- use IterableOps instead of IterableLike. IterableLike does not exists
- use iterator instead of toIterator https://github.com/scala/scala/blob/d94d9bc334de165bcdbefcf29ae05d8542549c4b/src/library/scala/collection/IterableOnce.scala#L80-L81
@scala-jenkins scala-jenkins added this to the 2.13.0-M5 milestone Jun 7, 2018
@lrytz lrytz merged commit 627b122 into scala:2.13.x Jun 7, 2018
@xuwei-k xuwei-k deleted the IsIterableLike branch June 7, 2018 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants