Skip to content

Commit

Permalink
Elaborate on Foldable#collectFirst comment (#2278)
Browse files Browse the repository at this point in the history
* Fix typo in Foldable comment

* Update Foldable.scala
  • Loading branch information
kubukoz authored and kailuowang committed Jun 11, 2018
1 parent f439fe0 commit 1d7ee78
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/Foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ import Foldable.sentinel

def collectFirst[A, B](fa: F[A])(pf: PartialFunction[A, B]): Option[B] =
foldRight(fa, Eval.now(Option.empty[B])) { (a, lb) =>
// trick from TravsersableOnce
// trick from TraversableOnce, used to avoid calling both isDefined and apply (or calling lift)
val x = pf.applyOrElse(a, sentinel)
if (x.asInstanceOf[AnyRef] ne sentinel) Eval.now(Some(x.asInstanceOf[B]))
else lb
Expand Down

0 comments on commit 1d7ee78

Please sign in to comment.